This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to forward a request to another server

 
Ian Moore
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ian Moore
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Byron, Sandy
Thanks for your replies, time to cut some code and see what happens !
cheers
Ian aka chinnermoore
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic