Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree. I think using a Filter will achieve this. Here is a Filter I wrote for load balancing and port redirection but it should be easy to figure out how to edit it to fit your needs.</p> <p>public class RequestWrapperFilter implements Filter {</p> <pre><code>public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; String requestWrapperClassName = (String) (httpRequest .getAttribute(LoadBalancerRequestWrapper.class.getName())); String initiatingServerName = httpRequest.getServerName(); if (requestWrapperClassName == null &amp;&amp; initiatingServerName.equals(loadBalancerHostName)) { httpRequest = new LoadBalancerRequestWrapper(AuthenticationUtil .getHttpServletRequest(httpRequest)); } filterChain.doFilter(httpRequest, httpResponse); } </code></pre> <p>}</p> <pre><code>/** * The custom implementation of the request wrapper. It simply overrides the * getScheme() and getServerPort() methods to perform the redirect * filtering. * * */ private static class LoadBalancerRequestWrapper extends HttpServletRequestWrapper { /** * Default Constructor. Simply declares the Wrapper as injected. * * @param httpServletRequest * the app-server HttpServletRequest. * */ public LoadBalancerRequestWrapper(HttpServletRequest httpServletRequest) { super(httpServletRequest); } /** * The overridden scheme. * */ public final String getScheme() { if (loadBalancerHttpScheme.equals(EMPTY_STRING)) { return super.getScheme(); } return loadBalancerHttpScheme; } } </code></pre> <p>}</p>
 

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