• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

storing parameters in request object

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am developing an application in which one jsp page is going to have 4-5 multiple select drop down boxes each generated dynamically with data from database and holding some thousands values in each.
Now I am confused as to whether I should first call a servlet to populate data in individual vector for each drop down and then use RequestDispatcher to forward request to a jsp page with storing all those vectors in request object. So that in jsp page, I can call custom tag library to display each drop down by passing each vector for each drop down.
Or is it a bad idea to store such huge vectors in request object and forwarding request?
Or I should do all processing in jsp page directly instead of servlet?
All gurus, please help me with this.
Thank you.
Niral
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Niral
IMO you should go with the servlet solution, or better yet have the servlet pass the data access job off to some 'business object' that builds the Vectors/ArrayLists/Whatever to populate the drop-downs. It is good practice to use JSPs only for presentation, so they should just get the data from beans, or objects stored in request or session scope, without any knowledge of where the data came from.
Michael
[ October 24, 2003: Message edited by: Michael Fitzmaurice ]
 
Niral Trivedi
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I am going to have business data object do the processing. Question is, I can directly call those Data objects in JSP and then use them right there in JSP. Or I can use servlet first for validation and populate data access objects and then pass them to JSP through request object.
Will storing these big objects in request and passing them make site slower in response?
Thanks.
Niral
 
Michael Fitzmaurice
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My answer is still the same - pass the data to the JSP - it should not know where or how this data was created. I don't see that passing the data in the request is a performance issue - if it really is a lot of data, the biggest expense will probably be in pulling it from the database, and that is something your JSP/Servlet design will not be able to help with.
If you add these objects to the request, you are not using any additional memory other than for the pointer, so putting them in the request will not have a significant effect on memory usage. Is your concern memory usage or speed of response?
How dynamic must these lists be? Could you cache them? I would do that if at all possible - pull all the data from the db at start-up time and hold it in memory.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael has given you excellent advice. I would follow it closely.
I think this is a concept that eludes many JSP authors. Placing data in the attributes of the various contexts doesn't use up any additional memory (except for the very minimal hash entries in the attribuye maps). You're already using up the memory; they do not get copied into the contexts.
Perhaps the confusion arises from admonitions to be careful about putting too much data in the session context. But this admonition has less to do with the amount of memory being used than with the longevity of that data.
bear
 
Niral Trivedi
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,
Thank you very much for your advise. That has helped clear my doubts about storing objects in request object and performance issue.
Thanks again.
Niral
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic