• 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

How To Pass the Request Scope to Another Class

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my ListThread class, I first retrieve some of the text fields; i.e., request.getParameter( ... );
Thereafter, I want to pass the request scope together with some parameters to another class; SiteUtil.java., for some further processing. This is what I do:

This is my SiteUtil.java:

Can I pass the request scope and save attributes in the scope this way?
 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where you will use that Attribute set in second class. Request scope might not be right place instead HttpSession or ServletContext should be right place to setAtrribute & use it anywhere in session or application.
Hope this help.
[ April 09, 2004: Message edited by: Nehul Nalekar ]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have found it more flexible to create another collection from the request, and pass that around as in this example.

With this approach, you can test and use your helper classes outside the servlet environment. Furthermore, you can't keep a request object past the end of the request/response cycle, but you can save that Map for any purpose.
Bill
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah that make sense if you want to save request level info & don't want to save into session or application. You can also save into database but that depends on requirement.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic