This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forwarding requests from web server to web server

 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may sound odd, but I would like advice on sending a request from one web server to another. For example, servlet S1 on web server A receives a requests and forwards it to servlet S2 on web server B. I know I can create a HttpURLConnection in servlet S1, but does anyone have any better suggestions? Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered using the sendRedirect method of HttpServletResponse? You have to use it before any text has been sent - it tells the user's browser to do a new request to the specified URL.
Bill
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply... Is that the only other way to get the job done?
 
Harpartap Singh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get the ServletContext of the OTHER web app.
Using this new ServletContext, create a RequestDispatcher to the servlet you want to access, and then forward your request...

Or something like this.
/hs
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic