IT Community - Software Programming, Web Development and Technical Support

JSP Tracking

This is a discussion on JSP Tracking within the Java Server Pages (JSP) forums, part of the Web Development category; I've always wanted to know more about JSP programming. How can I track sessions for JSP pages if the ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Java Server Pages (JSP)

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-09-2007, 11:35 AM
nhoj nhoj is offline
D-Web Programmer
 
Join Date: Apr 2007
Posts: 96
nhoj is on a distinguished road
Default JSP Tracking

I've always wanted to know more about JSP programming. How can I track sessions for JSP pages if the browser itself has disabled cookies?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-17-2007, 08:17 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 297
Karpagarajan is on a distinguished road
Thumbs up Re: JSP Tracking

A session is an object associated with a visitor. Data can be put in the session and retrieved from it, much like a Hashtable.

If you are programming the site, it is very helpful to be able to associate some data with each visitor. For this purpose, "session"s can be used in JSP.

Session variables have the following traits:
  • Unless specified otherwise, session variables expire 20 minutes after a visitor leaves the site.
  • Session variables will expire if no activity is detected on the site for 20 minutes by that specific site visitor, or if the visitor quits out of their web browser.
  • In order for session variables to work, the visitor's browser must be set to accept cookies.
  • The pages for the site all must be located within a single directory on the web server.
  • Information stored in session variables is site visitor specific. Different site visitors cannot access each other's session variable information.

Example

Use the session object like this...
<%
String name = request.getParameter( "username" );
session.setAttribute( "theName", name );
%>
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>
I hope it will be useful for you.

thanks
__________________
Karpagarajan. R
Necessity is the mother of invention

Last edited by Karpagarajan : 04-17-2007 at 08:19 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2007, 11:27 PM
prasannavigneshr prasannavigneshr is offline
D-Web Incredible
 
Join Date: Feb 2007
Posts: 1,316
prasannavigneshr is on a distinguished road
Send a message via MSN to prasannavigneshr
Thumbs up Re: JSP Tracking

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>
__________________
Prasanna Vignesh
MCPD | Web Developer

Last edited by prasannavigneshr : 04-17-2007 at 11:41 PM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of Bug Tracking Tools vadivelanvaidyanathan Testing Tools 2 06-30-2008 02:59 AM
Tips for Bug Tracking vigneshgets Software Testing 67 12-06-2007 01:34 AM
Tracking Server changes... what do all you do? vadivelanvaidyanathan Server Management 1 08-14-2007 12:44 AM
Tracking all DML and DDL Statements in Database Tables - MYSQL Murali Database Support 6 07-16-2007 02:31 AM
Nielsen Adds to Cellphone Tracking vigneshgets The Lounge 0 06-29-2007 05:29 AM


All times are GMT -7. The time now is 03:11 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0