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

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
0
AntoniRyszard656
Asked:
AntoniRyszard656
1 Solution
 
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

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