Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

request  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering exactly how long a request object lasts for. I am submitting some form data to a servlet. In certain instances the servlet forwards the request to a different servlet, which then goes to another jsp using :
request.getRequestDispatcher("/servlet").forward(request, response);
Do I still have access to all of the request objects parameters/attributes in the second servlet? And if so, can you forward to n servlets and still keep a hold of the request parameters/attributes?
thanks,
C.
 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think so. As long as you use forward(request, response) the request object will be passed all the way down.
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You definitely can, but I wouldn't suggest it. If you want to keep data "alive" for the invocation of several different servlets, try storing the data in a session.
-Stu
 
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Stu Glassman:
You definitely can, but I wouldn't suggest it. If you want to keep data "alive" for the invocation of several different servlets, try storing the data in a session.
-Stu



Stu, I would like to know why would you prefer storing information into the session instead of the request object? Of course it's the right way to go if the data shall be alive for multiple requests, but if the data needs to live just long enough for the final output (html) to be generated, why use the session?
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet's allows to fonward and include output from other servlets and even JSP in the same context ..
and eventually if you want to make a well role defined model .. you can make the controller logic on servlet and rely on other servlets or maybe on a JSPs to manage the response given to the user ..
 
Mario Rendon
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:


Stu, I would like to know why would you prefer storing information into the session instead of the request object? Of course it's the right way to go if the data shall be alive for multiple requests, but if the data needs to live just long enough for the final output (html) to be generated, why use the session?


completelly agree with Lasse the requst information shoud keept on request/response scope.. if you mix such information to Session level you pobably would have some problems with other request on the same session .
remeber even that even session means one user.. it doesn't mean a single thread nor a single concurrent request.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!