File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Resultset in session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Resultset in session" Watch "Resultset in session" New topic
Author

Resultset in session

Pallavi Srivastava
Ranch Hand

Joined: Dec 22, 2006
Posts: 38
Hi,

I am executing a query in a servlet and storing the resultset in a arraylist.Then I send the arraylist through session to jsp, for display.
I am noticing that executing query ,looping etc are not taking time but when I pass the request from servlet to jsp,it takes lot of time.
My resultset can be big containing 150 records or small depending on query.
How can I avoid this bottleneck.What are the other way I can send resultset to jsp so that time can be decreased?

Thanks.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A session is not much more than a map of references to Java objects on the heap so the size of a list should not affect the amount of time it takes to forward from a servlet to a JSP.

How did you come to this conclusion?

By the way: your current architecture follows all the accepted best practices for Java web apps. Passing a resultset to a JSP or storing it in session would be a step backwards, in my opion.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Pallavi Srivastava
Ranch Hand

Joined: Dec 22, 2006
Posts: 38
Thank you Ben for reply.
I have an asp application which searches records from db.It does all query,searching,business logic in one file.Now we have redesigned it based on j2ee architecture.All processing at servlet and then pass resultset to jsp using session.JSp does pagination etc.But I see somehow this application takes more time then original application.I am printing no of seconds at each step and maximum time taken is when I pass the request from servlet to jsp.
Thats is


Then on jsp I again get the time printed as soon as I retrieve the session.I see it takes maximum time at this step.Though db is large but no time is consumed in executing query.
Since this application is based on prev application so everybody expects same or atleast high performance from it.
Are there any suggestions?
Thanks again.
Pallavi Srivastava
Ranch Hand

Joined: Dec 22, 2006
Posts: 38
Sorry for double posting!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Pallavi Srivastava:
Sorry for double posting!


You can delete your own posts by clicking on the link. At the top left of the form is a checkbox for deleting the post.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Of course, the first call

may take more time if the jsp page has to be recompiled.

Do you get the same time delay pattern on repeated queries?

Bill
Pallavi Srivastava
Ranch Hand

Joined: Dec 22, 2006
Posts: 38
No,repeated queries doesnt take time.But when we enter new search criteria then it takes more time than previous application.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Then it sounds like the bottleneck is in the query execution.
Pallavi Srivastava
Ranch Hand

Joined: Dec 22, 2006
Posts: 38
Thank you Ben.
There is bottleneck in query execution only.
I am using jtds driver to connect to SQL Server.Is this making my application slower than original asp application?Are there other alternatives to increase performance?
Thanks again.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Are you using connection pooling or are you creating a new connection for each request?
Pallavi Srivastava
Ranch Hand

Joined: Dec 22, 2006
Posts: 38
I am using connection pooling and setting it up in Jboss Server.
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
I think you need to optimise your query. Build indexes on the table if the data is huge. If your earlier application is using pagination then it may be querying the small data which it want to display on each page rather than the whole chunk of data being stored in the Session.

For an Enterprise Application storing a huge chunk of data in the session object is not recommended. More over your application will go for a toss in a clustered environment as Session replication will fail for non serialized objects like Resultset.


Amit Tank
Linked In
 
wood burning stoves
 
subject: Resultset in session
 
Similar Threads
returning a resultset
JSP, Servlet & JDBC
set showplan_all on java
How to send the Resulset values to a JSP page from servlet?
HTML -> Servlet -> java bean -> JSP