Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on Christopher Schultz recommendation I tried this and it works.</p> <pre><code> package com.rama.test.jsessionfilter public class JsessionIdAvoiderFilter implements Filter { protected static final Logger LOGGER = LogManager.getLogger(JsessionIdAvoiderFilter.class); public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!(req instanceof HttpServletRequest)) { chain.doFilter(req, res); return; } HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; // Redirect requests with JSESSIONID in URL to clean old links /* If you really want clean up some old links which have Jsession id bookmarked clean it. If its new app this below check is not required. */ if (request.isRequestedSessionIdFromURL()) { String url = request.getRequestURL().append(request.getQueryString() != null ? "?" + request.getQueryString() : "").toString(); response.setHeader("Location", url); response.sendError(HttpServletResponse.SC_MOVED_PERMANENTLY); LOGGER.info(" Found url with jsession id in it:"+ request.getRequestURL() +": url="+url); return; } // Prevent rendering of JSESSIONID in URLs for all outgoing links HttpServletResponseWrapper wrappedResponse = new HttpServletResponseWrapper( response) { @Override public String encodeRedirectUrl(String url) { return url; } @Override public String encodeRedirectURL(String url) { return url; } @Override public String encodeUrl(String url) { return url; } @Override public String encodeURL(String url) { return url; } }; chain.doFilter(req, wrappedResponse); } public void destroy() { } public void init(FilterConfig arg0) throws ServletException { } } </code></pre> <p>and the following entry in web.xml</p> <pre><code>&lt;filter&gt; &lt;display-name&gt;JsessionId Filter&lt;/display-name&gt; &lt;filter-name&gt;jsessionIdAvoiderFilter&lt;/filter-name&gt; &lt;filter-class&gt;com.rama.test.jsessionfilter.JsessionIdAvoiderFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;jsessionIdAvoiderFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt; &lt;/filter-mapping&gt; </code></pre> <p>Works great !!!.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload