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 is the purpose of ?

506


What is the standard action?

594


What is out println in jsp?

523


What is jstl jar?

487


A jsp page, include.jsp, has a instance variable "int a", now this page is statically included in another jsp page, index.jsp, which has a instance variable "int a" declared. What happens when the index.jsp page is requested by the client?

654






Why should we not configure jsp standard tags in web.xml?

520


How to deactivate el on jsp?

519


Hi, I've applied for HPCL(Information System Officer)& UIIC (A).Plz send me previous/sample papers and any suggestions regarding this exam.Please advice me good study material or related links. Thanks in advance shyam shyamprasad71@gmail.com

1955


What are the jsp lifecycle phases?

556


Differentiate between include directive and include action.

499


What are the different scope values for the tag?

471


What is client side technology?

478


What is custom tag library?

485


Explain the various scope values for tag.

509


Can we override jsp service method?

476