my dog learned polymorphism
The moose likes Struts and the fly likes Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session" Watch "Session" New topic


dhaval tamboli

Joined: Aug 02, 2010
Posts: 25
Hi, I am making simple application .

First User will login using id and password . if thts correct then success.jsp page will open up and on that there is option to create agency mean just to enter new company information. (in which loginid is foreign key).

Now, I want to develop sessions but I am not sure from where to start cause I am not sure whether to do sessions on jsp page or struts2 action class or struts.xml.

I also want to be defined loginid as my session variable so that I can use it on any action class . and a normal login application like if user log out and log in

Defining loginid as my session variable is too much necessary cause Thats only way I can enter agency data into database as such loginid is foreign key.

I am using struts2 and hibernate and mySQL as database.

Looking forward for suggestions.

Ankit Garg

Joined: Aug 03, 2008
Posts: 9464

Dhaval please Use A Meaningful Subject Line when you start a topic.

I'm not really sure what your problem is, but if you want to set a session attribute then your action can implement the SessionAware interface. You'll get a Map which will have all the session attributes. You can add your loginid to this Map, that way it will be added as an attribute to the session. If you want to invalidate (end) the session, your action can implement ServletRequestAware interface. That way your action will get HttpServletRequest object from which you can get the HttpSession object and call the invalidate method...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: Session
It's not a secret anymore!