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 How To Pass the Request Scope to Another Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How To Pass the Request Scope to Another Class" Watch "How To Pass the Request Scope to Another Class" New topic
Author

How To Pass the Request Scope to Another Class

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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?
Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
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 ]

SCJP, SCWCD, SCBCD, SCJD, BB Java2 and JSP1.1
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
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


Java Resources at www.wbrogden.com
Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To Pass the Request Scope to Another Class
 
Similar Threads
How to Paging with Struts
findSuccess(Unknown Source)!!
Problems with paging i created
JTable Paging
string to int