Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resultset in session

 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for double posting!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,repeated queries doesnt take time.But when we enter new search criteria then it takes more time than previous application.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then it sounds like the bottleneck is in the query execution.
 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using connection pooling or are you creating a new connection for each request?
 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using connection pooling and setting it up in Jboss Server.
 
Amit M Tank
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic