Redirect to Login page

Gangadhara Melukote
Gangadhara Melukote used Ask the Experts™
on
This sounds like old question, but I am stuck in resolving the issue for my case.

I am working on very big web application which has more than 20 modules. We kept the header and footer in a sperate module and the header.jsp and footer.jsp are including in all other modules through  jsp:include  tag.

We are maintaining our own user entitlement model and I want to add user Role validation. If the user has roles in our entitlement, then redirect to PageA if not redirect to Login page (PageB).

After adding this piece of code in header.jsp, it is not redirecting to different page which I required. On googgling, found that if we are including any pages using jsp:include the page redirection code in header.jsp will never works.

Can someone please suggest the alternative ideas?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
mccarlIT Business Systems Analyst / Software Developer
Top Expert 2015
Commented:
Instead of using jsp:include are you able to use the below?
<%@include file="header.jsp" %>

Open in new window

Commented:
Agree with mccarl. You should use include directive if the included jsp contains a redirect statement.

The HttpServletResponse#sendRedirect() basically sets 302 as HTTP response status and target URL as HTTP Location header. It will be ignore if it is used in included jsp. Refer  http://docs.oracle.com/javaee/6/api/javax/servlet/RequestDispatcher.html#include%28javax.servlet.ServletRequest,%20javax.servlet.ServletResponse%29 for more info.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial