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 difference between javascript and jsp?
What are jsp el implicit objects and how it’s different from jsp implicit objects?
How can I use the results of my method? ea: <%! method (int x) { stuff return y; } %> <% out.println(y); %> how can I make this work? "y" is a variable made during the method.
How does el search for an attribute?
How can I prevent the use of scripts and java code on the jsp page?
Explain jsp:plugin action?
How do I mix jsp and ssi #include? What is the difference between include directive & jsp:include action?
How do we prevent browser from caching output of my jsp pages?
What is difference between sendredirect and requestdispatcher?
How many jsp scripting elements are there and what are they?
How can I override the jspinit() and jspdestroy() methods within a jsp page?
What are the different types of jstl tags?
What is custom tag library?
Why is _jspservice () method starting with an '_'?
What is jsp net?