wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Best way Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Best way" Watch "Best way" New topic
Author

Best way

Steven Lau
Greenhorn

Joined: Mar 25, 2002
Posts: 9
A Servlet S1 forwards a request to Servlet S2. The BEST way for Servlet S1 to pass data to Servlet S2 is by saving the data to
a) A Cookie.
b) The request object.
c) The ServletContext.
d) The HttpSession object.
Stephen Tallamy
Greenhorn

Joined: Jan 08, 2002
Posts: 16
I would suggest the answer is b) the request object. This is because it is only valid for the scope of the request.
Storing in the ServletContext could mean that another servlet could over-write the data.
Storing in Cookies makes no sense - these are for passing data to the client.
Storing in a Session would work but it would mean that the data would persist for the duration of the session which is probably not appropriate.
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
The best way is allways the way with the least possible side-effects.
So its request. The narrowest scope which can be used to pass the information should normally have the least possible side-effects.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best way
 
Similar Threads
Sort an array alphabetically and by length
getSource method and object comparison
How two different web application communicate with each other
Difference between String variable and String Object ???
Confused with String creation.