Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us
Website Load Testing
Auto Insurance Quote
Free Business Cards
Car Donations
Home Improvement
KVM over IP
Promotional Golf
KVM Switches
Server Racks
Promos and Premiums
Calling Cards
Disney World Tickets
Promotional Pens
Baby Photo Contest

Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Just because Web sites are easy to build these days, that doesn't mean it's easy to build a quality Web site that meets your business objectives.

Before developing your next Web site, or redesigning an existing site, download this Internet.com eBook to guide you through the process and plan your project, whether you're developing a site in-house or outsourcing the project.
Register now for your free Internet.com membership to download your complimentary eBook. Membership will also give you access to:

eBook library         Whitepapers         Webcasts
Newsletters         WinDrivers
Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

The Session Object

April 5, 2000

As we all know there are three commonly used 'ways' of maintaining 'state' with the stateless HTTP protocol. Cookies, URL re-writing and Hidden form fields in the HTML form. Session object or the session tracking API isolates the programmer from these implementation details. Although the actual implementation may be server dependant theoretically:

  1. The client request a particular page
  2. The server 'creates a session' with this client (by either sending a cookie with the session id or URL re-writing etc.).
  3. Every time the same client (identified by the cookie or URL) comes back to the server, the server uses this session id to provide a facility to 'put' and 'get' some session dependant information.
  4. This information can be accessed till the session is not: invalidated or timed out.

Servlet API makes the session tracking very simple.

In your code you can 'get' a session object associated with every user by :

HttpSession currSession = request.getSession(flag);

Where request is the HttpServletRequest object and flag is a boolean variable. 

  • When flag = true - A new session object is created for this user request.
  • When flag = false - This method returns the already created session object.
(Here the server uses the session ID it stored in the cookie or URL to identify the session Object).

To add any session variables we call:

	
currSession.putValue("userName",  Name);

This call will put the Name variable in the userName session value. (Note: it actually will put a reference and hence you can 'put' objects in the 'session').

To access a previously stored session variable:

	
String storedName =   currSession.getValue("userName");

We will write a simple web application which uses session values. But before that let's look at one more class in this package: RequestDispatcher.

Java Server Pages
Building Web Applications Using Servlets and JSP
Request Dispatcher


Up to => Home / Authoring / Java / Servlets




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers