Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting from j_securoty_check

Status
Not open for further replies.

mnellutla

Vendor
Nov 26, 2003
15
US
My application does a form based login on tomcat. whenever a protected page is called, if not logged in - login page pops up.

After authentication it goes to the page they wanted to go.

I want to know if there is anyway i can after authentication redirect to a page intermediate to the destination page and do something else?
[tt]
View protected page -- not logged--> Login page
| |
| |
logged in form based login
| (j_security_check)
| |
| |
| V
| mycustom.jsp
| |
| |
| redirect
|_________________ ____________|
|
V
dest.jsp
[/tt]
Something like this.
 
Hey mnellutla,
I've just done something similar to this, and found that the easiest way was to have a base JSP file that was protected by Tomcat. I would point a LOGIN link to this protected page, that was simply a res.sendRedirect("somepage.jsp").
Once the user is logged in though, everything is different, all the previously protected pages will now just slipstream; as long as the session remains active.
Hope that helps you out.

ooo. plus, i found a neet trick to force a LogOff in Tomcat. Create a LOGOFF link to LogOff.jsp; where LogOff.jsp is as follows:
Code:
<%
if (request.getParameter("logoff") != null)
{
  session.invalidate();
  response.sendRedirect("index.jsp");
}
%>


and that's all i have today.

Michael
 
Oops, left some of my other stuff in there. you only need a couple of lines in your JSP file. Exactly as follows will do the trick.

Code:
<%
session.invalidate();
response.sendRedirect("index.jsp");
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top