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 are the possible values for language directive?

487


How to include static files in a JSP page?

561


How do I perform browser redirection from a jsp page?

493


What is session tracking in jsp?

493


List all tags that are provided in jstl?

491






What is custom tag library?

481


Can an interface be implemented in the jsp file?

513


What is difference between custom jsp tags and beans?

551


How jsp is compiled?

474


Explain jsp action elements or action tags?

481


How we can disable session in jsp?

508


What are page directives?

515


How can I prevent the output of my jsp or servlet pages from being cached by the browser?

564


Can we define a class in a jsp page?

503


What is jstl core tags?

486