aspose file tools*
The moose likes Struts and the fly likes Login Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Login Problem" Watch "Login Problem" New topic
Author

Login Problem

Mattia Merenda
Ranch Hand

Joined: Dec 14, 2006
Posts: 47
Hi everybody,
I made an application that requires a login for the user.
It works fine but I have only one problem.The login is in the page index.jsp.When an user makes a correct login it is redirect to the page loginSuccess.jsp.
In this page there is a link to logout to go back in the index.jsp page.
I have an only problem with this login.
I want to disable the "Previous" button of the browser's window in the loginSuccess.jsp page.In this way,the user can make the logout only with the link that I made.
How is possible to disable that button with Struts?Should I use some method in my Action class for the login?Is there any example for this problem?
Thanks in advance,
Mattia.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Although there are sophisticated ways to disable the back button using JavaScript, it's usually very annonying to most users when you do so. If you're worried about the fact that the session is still active if the user hits the back button, there are other ways to make sure the session is invalidated. Example:

Putting the following scriptlet in index.jsp will insure that the session gets invalidated even if the user pressed the back button from the previous page to get there:

<% session.invalidate(); %>

This isn't fool-proof, though. The user could simply type another URL in the browser's URL line and navigate to another page. You just have to accept the fact that there will be a certain number of users who leave inactive sessions on your server. The web container will eventually get rid of them when they time out.


Merrill
Consultant, Sima Solutions
Mattia Merenda
Ranch Hand

Joined: Dec 14, 2006
Posts: 47
Hi Merrill,
your simple solution is not good for my project.
I want the user must not hit the button for the previous page.
Tell me some more complicated example.
Thanks,
Mattia
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
Out of curiousity, why can't the user go back to the login page when they are already logged in?

Even on my bank's website I can go back to the login after I logged in.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I still think it's a bad idea to try and disable the back button, but if you Google "JavaScript disable back button", you'll see some clever ways of doing it.
Ashish Tahasildar
Greenhorn

Joined: Dec 10, 2006
Posts: 12
Hi Merrill,
I appreciate your problem, but Is it not good to disable the back button when the user login and logout and tries to go back?
I too want the code to disable the back button.

Thanks,
Ashish
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
My main reason for saying that disabling the back button is a bad idea is that it annoys users. When I go to your website, I expect my browser to behave in a standard way, including an enabled back button. When I see that a site is trying to manipulate my browser to behave in non-standard ways, I will like as not just close the bowser and avoid the site.
[ January 04, 2007: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Login Problem
 
Similar Threads
Browser Closing without signout from site
how to disable the back button when the user logouts...
Again back button wiht logout link
logout from page with frames
enable web access from email url link