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
Who is Participating?
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.