code-gijoe
code-gijoe

Reputation: 7234

How to properly logout from GWT app to avoid browser loading cached data?

I have a corporate web app built on GWT that gets access via an external authentication module. My problem is :

If I type the URL of the login page again, the browser starts loading cached data I do not get to the login page. I have to hit reload to get to the login page. How can this be? What is so special about F5 that tells the browser not to use the cache?

I know the proxy does not get hit by any of my requests, meaning all the browser is doing is loading cached elements.

Someone has any clues?

Upvotes: 0

Views: 849

Answers (2)

user2025295
user2025295

Reputation: 11

I had the same problem. After logout GWT module not started.

<a id="logout" href="${pageContext.request.contextPath}/j_spring_security_logout">Logout</a>

The solution is very simple, it should be automatically refreshed before open a login page

in spring-security.xml

<security:logout logout-success-url="/logout.html"/>

logout.html

<head lang="en">
  <meta http-equiv="REFRESH" content="0;  url=login.html">
</head>

Upvotes: 1

Alex
Alex

Reputation: 11

I didn't clearly understand your problem, but I think I had a similar one. I hope it will be helpful for you.

I had my GwtPage.html and all the GWT stuff secured in web.xml.

When I visited http://example.com/GwtPage.html for the first time the container's security sent me to the login.jsp. And after login was done I was sent to the GwtPage.html, so all was fine.

But for the second time the GwtPage.html was cached by browser and the container didn't sent me the login.jsp. So I have done the following: I created index.jsp with only one line:

<%
    response.sendRedirect("GwtPage.html");
%>

And added it to the secured resources list.

Browsers don't cache it and so the container always send me the login page.

And the second benefit is that GwtPage.html remained cached by browsers, what is very good cause it is quite heavy.

My web.xml:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- Security -->
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Index Page</web-resource-name>
        <url-pattern>/index.jsp</url-pattern>
    </web-resource-collection>    
    <web-resource-collection>
        <web-resource-name>Main Page</web-resource-name>
        <url-pattern>/GwtPage.html</url-pattern>
    </web-resource-collection>
    <web-resource-collection>
        <web-resource-name>Gwt entrails</web-resource-name>
        <url-pattern>/Gwt/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>VIEWER</role-name>
    </auth-constraint>
</security-constraint>

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>myrealm</realm-name>
    <form-login-config>
        <form-login-page>/LoginForm.jsp</form-login-page>
        <form-error-page>/LoginError.jsp</form-error-page>
    </form-login-config>
</login-config>

Upvotes: 1

Related Questions