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 forward a request to another server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to forward a request to another server" Watch "How to forward a request to another server" New topic
Author

How to forward a request to another server

Ian Moore
Greenhorn

Joined: Jul 12, 2002
Posts: 4
I'm trying to write a servlet (on WebLogic) which will sit between legacy web applications (OAS) and users, such that users can make a request for the original application, the proxy intercepts this call (using an iPlanet plugin) and gets passed the original URL. This servlet should then forward the request to the legacy application after some security checks and setting up some variables.
Does anyone know how to forward the request on to these legacy applications which will reside on a different machine ??
Thanks in anticiaption
Ian Moore
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
chinnermoore
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!


Dave
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
Ian,
The forward() method on the RequestDispatcher won't work because the resource must be relative to the servlets root context.
It sounds like to me you are going to need to do some work with the java.net package that will allow you to generate HTTP connections, requests, etc. Basic stuff is pretty easy, but more advanced processing can get tricky.
I did a search and found the following...
Jetty
Note: I do not have any experience with this open source offering, but it appears to have a forwarding mechanism that does what you want to do. Even if you don't use it, it may give you a leg up in designing your solution.
Regards,


Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
Hi,
I guess its just your luck that i happened to have the same kind of problem and needed to do a bulk http post to some server. I used the org.apache.commons.httpclient package for the same.
For your legacy app u can use the HTTPClient, HttpPost classes under this package and post the request there(Post/Get Methods are available)
The problem here is reading the response from the legacy appln and then processing that to give the desired output. Seems like a lot of work but thats what u do with legacy app integration
HTH
Lemme know if u need the source code or more input
Sahil


Adios
Ian Moore
Greenhorn

Joined: Jul 12, 2002
Posts: 4
Byron, Sandy
Thanks for your replies, time to cut some code and see what happens !
cheers
Ian aka chinnermoore
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to forward a request to another server