aspose file tools
The moose likes Servlets and the fly likes When to use session? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "When to use session?" Watch "When to use session?" New topic

When to use session?

Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 168

Hi all i'm trying to send a request from an html form in which i'l provide emp id, uname, and basic salary amount. I want it to be stored in the salary table which contains empid, uname, b salary, hra, ta,da,gross,pf,net sal. can i use session in which it shoul first calculate vlues and store into database and should redirect the user and display salary slip onto the next page where the calculated amount will be called from a salary table and will be displayed in a desired format? Many thanks!!!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62298

Please read this article for a discussion of the best practice flow of control in web apps.

The session is sometimes used to preserve the data across a redirect using the PRG pattern, but it's not always the best way. Usually, in the PRG pattern, the data will be re-pulled from the database via the page controller of the redirect target. There usually isn't a need for the session except when it's been proven that caching data in the session solves a demonstrable performance issue.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
wood burning stoves
subject: When to use session?