Knowledge7

The Linux and Mobile Solution Provider

  • About
  • Training
  • Services
  • Clients
  • In the news
  • Blog
  • Contact Us
You are here: Home / Topic / Managing State

Managing State

This topic is part of our Web Application Development in Java training

HTTP is stateless.

As many applications require requests coming from the same client to be associated, web applications have the responsibility to maintain this state in a special object called a session. Fortunately, Java servlets fully support sessions.

Within a servlet, a session of class HttpSession is obtained by calling the getSession() method of the HTTP request. A session object can then be manipulated with getAttribute()/setAttribute()/removeAttribute().

After some time, a session expires. To control the lifetime of a session, the following methods are used: setMaxInactiveInterval() and invalidate().

Implementing a shopping cart

Enhance the web application developed previously so that users can add specific songs to a shopping cart. Multiple users browsing from different computers should be able to have their distinct shopping carts. Each user should be able to clear his own cart at any time.

Back.

This topic is part of our Web Application Development in Java training

Our forthcoming training courses

  • No training courses are scheduled.

Leave a Reply

Your email address will not be published. Required fields are marked *

Looking for something?

Want to know more?

Get our newsletter

Discover the latest news, tips and tricks on Linux, the Web and Mobile technologies every week for FREE

This work is licensed by Knowledge7 under an Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.