Trying to logout with JAAS Form based authentication
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Zeev_Sander
Posted On:   Tuesday, June 29, 2004 05:12 AM

hi folks

Is there some way to logout?

I use JBoss based on Tomcat 4.1.29. It has the servlet 2.3 specification, which does't support invalidateAll() and logout() menthods for HttpSession.

session.invalidate() has no effect.


PLEASE HELP!!!

Re: Trying to logout with JAAS Form based authentication

Posted By:   Vincenzo_Sorrentino  
Posted On:   Monday, July 19, 2004 04:13 AM

Consider two page login.jsp and index.jsp

- login.jsp is the page containing a form with login and password
- index.jsp is your main page

I've resolved a problem adding this code in the login page:

<%
//not authenticated
if( request.getUserPrincipal()==null ) {
String requestURL = request.getRequestURL().toString();
if (!requestURL.endsWith("/index.jsp")) {
String redirectURL = request.getContextPath().concat("/index.jsp");
System.out.println("redirect URL: " + redirectURL);
response.sendRedirect( redirectURL );
}
}
%>

If I click on logout link I invalidate a session and redirect the control on index.jsp

If instead I click on another link and the session was expired automatically a control go on login page and the code above redirect on login page

try it

Good Luck
Vincenzo
About | Sitemap | Contact