File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Session Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Data " Watch "Session Data " New topic

Session Data

Shivani Patel

Joined: Nov 01, 2001
Posts: 11
Hi ,
This is a Design issue.
I am working on web application in which one user requires to navigate around 50 avg pages. And on each and every page there are arnd 10 fields.
And each value from 1st page to last page requires in between the pages for calculations and for editing purposes.
So my question is where should i save this data ? which users has entered on 1st page and other subsequent pages. In
1) Session
2) File
3) Database (For Temporary purpose)
4) XML
5) Any other
There will be maximum arnd 100 alive users.
And the finally at last the data will not be stored in to the database, but in to the XML file.
Say if im selecting Session then more n more memory will be accupied by unnecessary data,
which is not a effiecient way. But as the data will be of arnd 1 MB per user i think that can be
managable from the application server point of view.
If 2 File (I/O)
The memory use by application server will be less.
If 3 Database
As the data is not required to stored in DB and in between we are not going to use the
Database features why unnecessary store the data and increase the network traffic between
app server and DB.
If 4 XML
If i use DOM then what will be the size of memory? I think it will be the same as of Session (1 MB DOM size per user).

But here comes the question of the best solution.
What will be the Best?

Shivani Patel,<BR>N InfoNET Pvt. Ltd
Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
I would rule out XML and file idea straight away.
Now, let's look at the other two options...
1. You said there will be about one Meg of data per user session and there will be about 100 users.
This data by itself carries little information because ...
The number of user sessions may be much more than the number of users ... because of the following reasons ...
1. One user logs with multiple browser windows and hence ... multiple sessions.
2. One user performs some transactions, closes the browser, opens a new browser and carries on with a new transaction. The old session still remains at the server, till it times out.
With no other facts given, I would assume about 150 user sessions.
On the other hand, I thing the actual amount of data in the session ( per session ) will be less than 1 Meg. An users total volume of session data will reach 1 Meg only when he reaches the 50th page. On an average I would take .75 Meg of data per session.
Therefore the total load on the heap memory will be .75 * 150 approx 115 Meg.
With this I would add the normal objects that are created in the heap memory during normal execution of the application, and the memory space taken up by your server. So this figure will rise considerably higher. And you are working with DOM, which eats up huge memory !!!

Any machine which will act as a server will atleast have 256 Meg of memory ... or more realisticallly 512 Meg of memory, thus you are safe ... but ensure that your box only hosts your web application and nothing else !!!

Now the database solution. Database calls are optimized, but continuous updation of database with huge volumes of data as estimated above will hog the network. This will probably make your application terribly poor in performance.
You said that your application by itself does not make use of a database. Just to store some temporary data, the buying of a database licence is not at all a cost effective solution. Even if you have a database already ... using your application to connect to the existing database ... the performance of the other applications which relies on this database will be hampered.
I would rather go for the session, than a database. However, make sure your application is fine tuned for performance.

I agree. Here's the link:
subject: Session Data
Similar Threads
data mixup for two responses
Help needed to understand JConsole output and JVM settings
use of scope in useBean tag and session in page tag
Tomcat & Memory
Test 252: Mock exam