This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Sending argument from one servlet to another servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Sending argument from one servlet to another servlet" Watch "Sending argument from one servlet to another servlet" New topic
Author

Sending argument from one servlet to another servlet

Satish Kota
Ranch Hand

Joined: Feb 08, 2006
Posts: 88
Hi Ranchers,
I would like to know how to send an argument(s) from one servlet to another servlet. I know this can be done by using setAttribute and getAttribute methods of ServletContext class. But storing data in servlet context would make it visible to all other servlets. Is there any other way to implement this?


SCJP 5.0 77%
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can also bind your objects to request or session scoped objects before forwarding. In addtion, you can use hidden form fields or querystring variables in your pages.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 423
Yes Ben is right, use request.setAttribute() and request.getAttribute() and your values will be available to those two servlets only. I personally use hidden fields ie <input type="hidden" name=myname value=myvalue> mostly.

Maki Jav


Help gets you when you need it!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Sending argument from one servlet to another servlet
 
Similar Threads
How to update the browser address with the displayed page
applet to applet communication
doPost() processes - doGet() displays
Use filters to change the jsp file called by a servlet?
Servlet Calling Public Methods of Another Servlet