Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes Back button problem on logout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Back button problem on logout" Watch "Back button problem on logout" New topic
Author

Back button problem on logout

Deepa More
Ranch Hand

Joined: May 22, 2006
Posts: 68
I am using Struts1.2 framework.
On logout I call LoginAction which invalidate session.
The problem is browser's back button problem as users information remains.
I have read posts related to this which mentions setting headers in response object like Cache-Control,Expires and Pragma.
But I have lots of jsp pages, so do I need to include part of setting response header in all jsp pages? Is there any better option to do this at one place?
Also I tried setting "controller" tag in Struts-Config.xml where "noCache" can be specified but there are some static jsp pages for which there is no action written and these are called directly using anchor tag, so facing same back button problem for these pages. Do I need to change calling of static jsp pages?
I want central point to control this, dont want to set response headers on each jsp page. How do I solve this?

Thanks
Deepa
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It looks like you've already explored most of the options that are available to you. In my opinion, setting "noCache" in the controller stanza of the struts-config.xml file is the best option in spite of the drawback you mentioned. One possible workaround for the static pages is to have them served directly from your HTTP Server. In a typical production installation, there is an HTTP Server up front which forwards to the Application server. You could simply keep all your static content in the HTTP Server's context.


Merrill
Consultant, Sima Solutions
Deepa More
Ranch Hand

Joined: May 22, 2006
Posts: 68
You could simply keep all your static content in the HTTP Server's context.

What do you mean by this?
I am using Apache tomcat5 server and back end as MySQL db.
Do you mean the call to static pages has to undergo via struts-config.xml
i.e. there might be some forward to call these pages?
Or anything else?
Please explore.

Thanks
Deepa
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'm used to working with IBM's WebSphere Application Server. In the topology most often used there is a separate Apache HTTP Server that in turn forwards requests to the application server. This Apache Server can serve static pages without forwarding to the app server. It would be set up so that any URI with a suffix of ".do" or ".jsp" gets forwarded to the app server, but other requests would be served from the static server. You would then set up a folder in the HTTP Server's context with the same name as your Struts application. That way the page http://myserver.com/myApp/mystaticPage.html would be served from the HTTP Server and the page http://myserver.com/myApp/mydynamicpage.jsp would be served from the app server. You could then easily use the static page URL as a forward in your Struts application. If you did this, the Struts "noCache" directive would not apply to the static pages.

I believe you could set up such a topology with Tomcat, but I'm afraid I don't know the details of how to do it.
[ April 21, 2008: Message edited by: Merrill Higginson ]
Deepa More
Ranch Hand

Joined: May 22, 2006
Posts: 68
Thanks for reply.
I solved my problem with the help of these posts:
http://www.symphonious.net/2007/06/19/caching-in-tomcat/
and
http://www.coderanch.com/t/290800/JSP/java/Invalid-url-pattern-filter-web
I used filter concept of servlet.

Thanks
Deepa
[ April 24, 2008: Message edited by: Deepa More ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Back button problem on logout