• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Using sessions in java servlet?


Could anyone demonstrate how to delete a session within servlet's.

I would also like to timeout sessions, to achieve this would I need to set a timeinterval value web.xml file of tomcat?

And finally, I am using tomcat and passing a javabean between the servlet and jsp page.

My text book says the javabean class declaration should implement Serializable. Is this correct with all javabean classes?

Thank you
1 Solution
You have a method HttpSession.invalidate() to teminate your session.

Session timeout in web.xml
          <session-timeout>30</session-timeout><!-- time in minutes -->

Javabeans require to implement Serializalbe interface. Its a marker interface, means it doesnt have any methods in it.
The classes that implement Serializable interface, the objects of that class can save its state.
This is helpful when u are transfering objects thru network.
But its a good practice that your javabean classes implement Serializable, whether or not you send them thru network.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now