What are the methods in HttpSession and their use?

Answers were Sorted based on User's Feedback



What are the methods in HttpSession and their use?..

Answer / niranjanravi

getId()
getLastAccessedTime()
getCreationTime()
putValue()
getAttribute()
setAttribute()

Is This Answer Correct ?    10 Yes 2 No

What are the methods in HttpSession and their use?..

Answer / kaushal

o getCreationTime()
Returns the time at which this session representation
was created, in milliseconds since midnight, January 1, 1970
UTC.
o getId()
Returns the identifier assigned to this session.
o getLastAccessedTime()
Returns the last time the client sent a request carrying
the identifier assigned to the session.
o getMaxInactiveInterval()
o getSessionContext()
Returns the context in which this session is bound.
Deprecated.
o getValue(String)
Returns the object bound to the given name in the
session's application layer data.
o getValueNames()
Returns an array of the names of all the application
layer data objects bound into the session.
o invalidate()
Causes this representation of the session to be
invalidated and removed from its context.
o isNew()
A session is considered to be "new" if it has been
created by the server, but the client has not yet
acknowledged joining the session.
o putValue(String, Object)
Binds the specified object into the session's
application layer data with the given name.
o removeValue(String)
Removes the object bound to the given name in the
session's application layer data.
o setMaxInactiveInterval(int)
Sets the maximum interval between requests that this
session will be kept by the host server.

Is This Answer Correct ?    5 Yes 2 No

What are the methods in HttpSession and their use?..

Answer / amit tomar

getAttributesNames()
getId()
getLastAccessedTime()
getCreationTime()
putValue()
getAttribute()
setAttribute()

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More Servlets Interview Questions

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

2 Answers  


hi.... i have problem in running of servlet. i am using Tomcat server in my pc.. The problem is when i am click on strat it will display like below FAIL - Application at context path /first could not be started.. How i can slove the problem.. help plz

3 Answers  


What’s the difference between sendredirect and forward methods

0 Answers  


Why servlet is faster than jsp?

0 Answers  


How do you communicate in between Applets and Servlets?

0 Answers  






Name the servers that can be used to develope and deploy Servlets?

1 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 servlet chaining?

0 Answers  


What is meant by session? Tell me something about httpsession class?

0 Answers  


Why is a constructor needed in a servlet even if we use the init method?

0 Answers  


how can you give alias to servlets?

1 Answers  


What is done after deploying a war file and before client gives a request

2 Answers   Bosch,


Categories