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 server side programming language?
How can we use beans in jsp?
Is jsp compiled?
Can a subsequent request be accessed with one’s servlet code, if a request attribute is already sent in his jsp?
How can my application get to know when a httpsession is removed?
Which attribute specifies a jsp page that should process any exceptions thrown but not caught in the current page?
What is expression language in jsp?
What are the types of directives in jsp?
What is tld file?
What is el in jsp?
Which one is better jsp or servlet?
Is jsp a front end?
How can we forward the request from jsp page to the servlet?
How do you prevent the creation of a session in a jsp page and why? What is the difference between include directive & jsp:include action?
Can we use jsp implicit objects in a method defined in jsp declaration?