Solved

Manage session with jsp/servlet

Posted on 2001-09-17
7
708 Views
Last Modified: 2013-11-24
Hi,

I have an intranet web application which is based on java servlet & jsp.
What is the best way to manage a user session ? & how ?



0
Comment
Question by:kingasa
7 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 6487021
servlet API supports session management by default

read
javax.servlet.http.HttpSession documentation.
0
 

Expert Comment

by:sujatharathinam
ID: 6487062
In jsp just write
<%
request.getSession(true);
session.putValue("name",suja)
%>
while trying to get the session value..
just write
<%!
String name1;
%>
<%
name1 = (String)session.getValue("name");
%>
You can also store a array in a session.
In Servlets just instantiate HttpSession and then try to use the same code.
All The Best
0
 

Author Comment

by:kingasa
ID: 6487424
Just posted this Q please allow other pepole to comment.

How do I get the parameters values entered in one jsp from another jsp.

when will I use any of the technologies available,
url rewriting, cookies , etc..
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Accepted Solution

by:
andycandy earned 50 total points
ID: 6488895
hello kingasa!
HttpSession object instance is shared betwen every jsp pages and servlets wchich are requested by the same agent(browser I think) unless the user close the browser or session invalidate(the session timeout is specific for each servers, even for application and is configureable (see deployment descriptor or documentation for server and j2ee application)).
So,be sure you ommit the same parameter and its value from HttpSession object  on each jsp page and servlet.

If OrionServer is your server i can give you better approach.

Example
file://first.jsp
.
.
.
<%
 session.setAttribute("foo",new Integer(5));
%>
.

file://second.jsp
.
.
<%= session.getAttribute("foo")%>
...


you will see ..  5  .. instead of it


sorry for my english!

"8-) Andy


0
 

Author Comment

by:kingasa
ID: 6489535
when will I use url rewriting, cookies , etc..
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6490163
it seems that this question is quite attractive :)

most servlet engines have some configuration files that allow you to specify if you want to use cookies or URL rewriting - servlet engine handles all the low level stuff.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6727897
This question is LOCKED with a Proposed Answer.  If it helps you, great, accept it and grade it to close.  If not, reject it and comment as to why or what else is needed.

Few additional experts will join this collaboration effort, once a question has been locked.  Just want to confirm this to you.  If more than one expert helps you, you can always split points or award additional help in a new question, within the same topic area.  If you need help from us, post a zero point question here, and include the link:

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question