How many ways to remove the session object in the container

Answers were Sorted based on User's Feedback



How many ways to remove the session object in the container..

Answer / sekhar babu

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

How many ways to remove the session object in the container..

Answer / ashwin kumar j

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

How many ways to remove the session object in the container..

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

How many ways to remove the session object in the container..

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

How many ways to remove the session object in the container..

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

How many ways to remove the session object in the container..

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

Post New Answer

More Servlets Interview Questions

What do you mean by deployment descriptor?

0 Answers  


Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?

0 Answers  


What is getservletcontext?

0 Answers  


Is the init(ServletConfig sc) throws IOException or not?

3 Answers  


Write a program to show the functionality of doget and dopost method?

0 Answers  






What is the difference between callling a RequestDispatcher using ServletRequest and ServletContext?

2 Answers  


Explain the difference between a web server and a web container?

0 Answers  


hi actully i hav form columns with origin and destination names .as like as i need to create one more column with name amount. my requirement is when i select origin and destination columns automatically i need to get amount from database.how can i. please tel me with relative code

0 Answers   CTS,


What is life cycle of Servlet?

0 Answers  


Define context initialization parameters.

0 Answers  


What do you mean by cgi?

0 Answers  


Explain the war file?

0 Answers  


Categories