Solved

Manage session with jsp/servlet

Posted on 2001-09-17
7
711 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

717 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