The Artima Developer Community
Sponsored Link

Web Services Forum
How to do session tracking in JSP

8 replies on 1 page. Most recent reply: Mar 30, 2010 10:41 AM by vamsi krishna

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 8 replies on 1 page
Richard

Posts: 1
Nickname: hy1946
Registered: Jul, 2002

How to do session tracking in JSP Posted: Jul 8, 2002 10:06 AM
Reply to this message Reply
Advertisement
I want to do session tracking in my JSP pages.Say once after the user logs in,on every page I can get his username for further use.Thank you for your help!
Richard


keith

Posts: 1
Nickname: keithjava
Registered: Sep, 2002

Re: How to do session tracking in JSP Posted: Sep 16, 2002 8:36 PM
Reply to this message Reply
First we have a form, let us call it GetName.html

<HTML>
<BODY>
<FORM METHOD=POST ACTION="SaveName.jsp">
What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20>
<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
The target of the form is "SaveName.jsp", which saves the user's name in the session. Note the variable "session". This is another variable that is normally made available in JSPs, just like out and request variables. (In the @page directive, you can indicate that you do not need sessions, in which case the "session" variable will not be made available.)
<%
String name = request.getParameter( "username" );
session.setAttribute( "theName", name );
%>
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>
The SaveName.jsp saves the user's name in the session, and puts a link to another page, NextPage.jsp.
NextPage.jsp shows how to retrieve the saved name.

<HTML>
<BODY>
Hello, <%= session.getAttribute( "theName" ) %>
</BODY>
</HTML>

Good

Posts: 2
Nickname: george
Registered: Sep, 2002

Re: How to do session tracking in JSP Posted: Sep 17, 2002 8:38 AM
Reply to this message Reply
Above code is Perfect

Rene

Posts: 1
Nickname: rene
Registered: Dec, 2002

Re: How to do session tracking in JSP Posted: Dec 2, 2002 10:29 PM
Reply to this message Reply
Excellent

sudhakar

Posts: 2
Nickname: mars
Registered: Oct, 2004

Re: How to do session tracking in JSP Posted: Oct 23, 2004 8:50 AM
Reply to this message Reply
very nice example ,

please send me more documentation with examples examples

sudhakar

Posts: 2
Nickname: mars
Registered: Oct, 2004

Re: How to do session tracking in JSP Posted: Oct 23, 2004 9:24 AM
Reply to this message Reply
when i run the same program next time , I am getting the same "username" what I gave in the first time .

I expect I should get "username" what I submit now.

sudhakar

neeraj

Posts: 1
Nickname: neerajna
Registered: May, 2005

Re: How to do session tracking in JSP Posted: May 9, 2005 1:47 AM
Reply to this message Reply
Kutte Kamena

RoseIndia.net

Posts: 1
Nickname: roseindia
Registered: Oct, 2005

Re: How to do session tracking in JSP Posted: Oct 2, 2005 9:14 PM
Reply to this message Reply
There is very good tutorial on session tracking in JSP.

Visit http://www.roseindia.net/jsp/jspsessions.shtml

Regards
RoseIndia.net

vamsi krishna

Posts: 1
Nickname: vamsi12345
Registered: Mar, 2010

Re: How to do session tracking in JSP Posted: Mar 30, 2010 10:41 AM
Reply to this message Reply
thank you

Flat View: This topic has 8 replies on 1 page
Topic: Multi-Tier SOA Deployment Previous Topic   Next Topic Topic: Connection to SQL Server 2000 with JDBC 4.0

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use