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
What are the possible values for language directive?
How to include static files in a JSP page?
How do I perform browser redirection from a jsp page?
What is session tracking in jsp?
List all tags that are provided in jstl?
What is custom tag library?
Can an interface be implemented in the jsp file?
What is difference between custom jsp tags and beans?
How jsp is compiled?
Explain jsp action elements or action tags?
How we can disable session in jsp?
What are page directives?
How can I prevent the output of my jsp or servlet pages from being cached by the browser?
Can we define a class in a jsp page?
What is jstl core tags?