aspose file tools*
The moose likes Servlets and the fly likes how to send the request to another sevlet 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 send the request to another sevlet" Watch "how to send the request to another sevlet" New topic
Author

how to send the request to another sevlet

sudhakar papireddy
Greenhorn

Joined: Jan 10, 2008
Posts: 9
hi
i have two sevlets. The request always comes to first servlet with one parameter. I would like to send the request to another servlet depends on the parameter value.

can some one help on this. how we can send the request from one sevlet to another?

Thanks
Sudhakar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
You could either do a client-side response.sendRedirect or a server-side RequestDispatcher.forward (or include). The latter will preserve request information and attributes (which are lost when doing the former).


Ping & DNS - updated with new look and Ping home screen widget
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Let's say that you have a JSP page that sends a String conatins the name of the servlet to go to.
Your first serlvet receives this request, and it can have this code to decide the next servlet to go:


Hope it helped...


Qussay NAJJAR
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27

It really goes without saying, but silently ignoring exceptions is of course something you should almost never do, and definitely not here.
[ January 19, 2008: Message edited by: Ulf Dittmer ]
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
You're completely right Sir, for sure i didn't catch the exception for nothing, but i was just showing an example.. really thanks for the note..
Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
i think we can also use Query String!


Perform for today. Adapt for tomorrow.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to send the request to another sevlet
 
Similar Threads
Using a servlet to initiate a request
Request Attributes
Reading the file
More Than One Object To A Servlet
passing large data to a servlet