We'd like to have a Logout button on our GUI, but we are unable to get
GWT to perform the logout.
The button has a call to an RPC method and in the servlet
implementation of the RPC call we have code like the following.
public void logoutUser() {
HttpServletRequest req = getThreadLocalRequest();
HttpSession session = req.getSession();
session.invalidate();
weblogic.servlet.security.ServletAuthentication.logout(req);
}
The last API is a weblogic specific API, but I would think killing the
session should do the same thing.
The problem is that if the GWT GUI is still active, the user can click
on another element and the session will be reestablished.
I guess we could disable the main GUI of the the app. In our case the
code for the logout button is in our main application module.
What are other folks doing?
Because you invalidated/killed the session the browser cookie should
now be invalid and so the user would need to reauthenticate.
The problem I have is if I have my server running, open a browser
login, use my logout button as shown and then come back to the site,
I'm still logged in. It is almost like GWT is remembering the session
and that is somehow cached in the browser.
Dave
i'm not sure about what j2ee security model your talking, but we use in
our app a filter which checks if the user is logged on.
so my logout link refers to a jsp which basically just does this:
<%
session.invalidate();
response.sendRedirect("redirect.jsp");
%>
and the redirect page does
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<c:redirect url="index.html"/>
And as the session is invalidated, the filter recognizes the new page
load as new user, so he needs to authenticate himself again.
Hope this helps.
Dominik