Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tracking the Session in struts

 
Neeraj jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am implementing IntranetMailServer using struts and i need to store the username in session to use it in future for fetching mails etc. but the problem is that from login page the request directly goes to the LoginAction class which is extended from the ActionSupport class so tell me where i do set the Attribute in session......... and also i need to track the session so noone can directlyy reach to the inbox without having login so how to achieve it as i tried it with


when i send the request 1st time it redirects me to the login.jsp with the particular message but when i again send the request it opens welcome.jsp please resolve it as i don't want user to go into inbox without having to login
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18169
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd actually be a lot safer if instead of writing your own security system, you used the one that's part of the J2EE standard. I've never seen a DIY security system that was truly secure (most of them are VERY insecure). And you wouldn't have to store the userID anywhere, because it would be available from the HttpServletRequest getRemoteUser() and getUserPrincipal() methods.

Plus, your goal of guarding against people simply walking around the login URL (one of the most common ways to exploit DIY systems) is taken care of automatically by the server. You set the access controls in web.xml based on the incoming URL pattern match. If someone attempts to submit a protected URL, the server itself forces a login and they cannot exploit your code, because the server won't send the URL on to your app until they've logged in.
 
Neeraj jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim thanks for such a wonderfull explaination will you please also give me the example what you have explained above i mean that web.xml
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic