How many ways to remove the session object in the container
Answers were Sorted based on User's Feedback
To remove the session object .
1. with the help of web.xml
<session-timeout>time in minutes</session-timeout>
2. in programatically
session.setMaxInactiveInterval(time in seconds)
to terminate immediately the session
use session.invalidate()
Is This Answer Correct ? | 23 Yes | 0 No |
session.invalidate() used to kill the session object,this
method is usually called, for ex: when we logoff from an
application.
and
session.removeAttribute()
Is This Answer Correct ? | 16 Yes | 3 No |
Answer / kishore
Session objects can be removed in three ways.
1> session.invalidate() - will remove all session objects
2> session.removeAtttribute(objName); - will remove the
specified object
3> session.setAtttribute(objName,null); - will remove the
specified object
Is This Answer Correct ? | 6 Yes | 2 No |
Answer / ravikiran
1).request.getSession().invalidate();
2).request.getSession.removeAttribute("obj");
3).Adding the following code inside the web.xml
<session-config>
<session-timeout>mins</session-timeout>
</session-config>
4).calling the seMaxInactiveInterval(seconds);
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / amitasite
Programmatically:
1. session.invalidate()
2. session.setMaxInteractiveIntervals(0);
Container will remove session if user is idle more than the
time specified in <session-timeout>time in
minutes</session-timeout> in web.xml
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / shyamalendu prusty
If you are using HTTP Session then you can use
session.remove().
But if you are using some other ways for session management
let’s say cookies then you have to then you can setMaxAge
to zero for the cookie.
Is This Answer Correct ? | 5 Yes | 9 No |
What is the use of httpservletrequestwrapper?
What is the use of request dispatcher interface?
How to debug a servlet?
What are the ways to handle multi-threading in servlets?
What are the jobs performed by servlets?
In the servlets, we are having a web page that is invoking servlets ,username and password? which is checks in database? Suppose the second page also if we want to verify
How can you maintain servlet chaining?
What are different types of Servlets?
What is servlet used for?
What’s the difference between sendredirect and forward methods
How do I support both get and post from the same servlet?
how to link html file to sevlet file.one name is textbox,c&c++ is cheakbox,bc&mca is radio button and one submit buttonis ok why in this programme use in servelt file