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 is declaration statement?
Explain the difference between include directive and include action in jsp?
Can a subsequent request be accessed with one’s servlet code, if a request attribute is already sent in his jsp?
What are the life-cycle methods for a jsp?
Tell us about the jsp life cycle methods.
What is jsp and its advantages?
What is the use of jsp and servlet?
What is jsp container?
How does error handling occur with jstl?
What is jsp param?
How are the jsp requests handled?
What is the difference between server side and client side programming?
How many tags are provided in jstl?
How do we catch exception and process it using jstl?
How do you comment out in jsp?