how to maintain sessions in jsp?can you tellme the methods.

Answer Posted / tarak

In the state page u have to set the session
<% Session ses=request.getSession(true);%>
Then set an atribute for the session.
<% ses.setAttribute("attribute","valid session");%>

Session: <% =ses.getAttribute("attribute");%>

(It will display Session: valid session)

Before you close or logout invlidate the session and remove
attribute
<% ses.removeAttribute("attribute");
ses.invalidate();%>

Everytime at the start of page we can check for the value
of sesion attribute. If it is set, then the session will be
valid. Otherwise invalid session.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What information is needed to create a tcp socket?

518


What does jsp mean in text?

476


What are the different types of jstl tags?

510


What is a page directive?

513


How are jsp(java server pages) better than asp(active server pages)?

482






What is the requirement of a tag library?

540


What is the jsp?

549


What is jsp api?

486


What is jsp life cycle?

505


How to send data from jsp to jsp?

515


Explain the difference between include directive and include action in jsp?

529


What is difference between javascript and jsp?

502


in jsf page i use two dropdown list.i.e state & district.if state dropdown is selected then & then district is enable.what should be my code.

2088


Explain how you understand the action tag and jsp action elements.

554


How to include static files in a JSP page?

570