Using sessions in java servlet?

Hello,

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
AntoniRyszard656Asked:
Who is Participating?
 
avinthmCommented:
You have a method HttpSession.invalidate() to teminate your session.

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

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.
0
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.