• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts Login/Logout Form

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to develop a login/logout form using Struts. Please have a
look at the following sample code.

---LoginAction---

public class LoginAction extends Action{

public ActionForward execute(ActionMapping mapping, ActionForm
form, HttpServletRequest request,HttpServletResponse response){

LoginForm f = (LoginForm)form;

String userName = f.getUserName();
String passWord = f.getPassWord();

if(userName.equalsIgnoreCase("username") && passWord.equalsIgnoreCase("password"))
{
session.setAttribute("userName", userName);

}

return(mapping.findForward("success"));

}

}

And in the LogoutAction, I do session.removeAttribute("userName") and
do a session.invalidate().

The problem is whenever I press the back button of the browser, It
again goes to the page which is supposed to be shown only to user
logged in successfully. Am I doing something wicked ?

I am using struts 1.2.9 and have to do it using the Struts 1 and not Struts 2.

Thanks for your help/suggestions.
-
KFC
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The issue is with browser which caches the pages you visit recently ..

This problem is discussed many time, search the forum for 'Disabling browser back button' or 'logout + back button ' keywords . Or you can googled it out. .

And pl change your display name as its not adheres to JavaRanch Naming Policy .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic