Skip to content

Instantly share code, notes, and snippets.

@exhesham
Last active October 10, 2018 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exhesham/886c4bbc2e13bcfc4ad805d941e33a64 to your computer and use it in GitHub Desktop.
Save exhesham/886c4bbc2e13bcfc4ad805d941e33a64 to your computer and use it in GitHub Desktop.
public class FilterLogin implements Filter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain){
// inject cookie
Cookie c = getCookie(httpServletResponse, "WASReqURL");
if(c == null){
// inject the cookie if it is not there
c = new Cookie("WASReqURL", "");
httpServletResponse.addCookie(c);
}
String newUrl = "/my_action_servlet";
// update the cookie value with the new url
c.setValue(newUrl);
// continue to the j_security_check
chain.doFilter(request, response);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment