Solved

Manage session with jsp/servlet

Posted on 2001-09-17
7
704 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now