Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forwarding a request to a sevlet inside context on another web server.

 
Ashish Agrawal
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written one servlet from which I want to pass the objects created in it to a servlet on another server. I have tried it with the sendRedirect method. It is working fine for simple strings when appended with the url query string, but how can I send bulk amount of data with the request and also have a response from there?
I have also tried using forward method, but it doesnt work for remote contexts even if a reference to remote context is acquired.
 
Roland Barcia
author
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A forward stays on the server and is part of the same request. So you can store data as an attribute and forward. If you need to redirect to a Servlet that is part of another application on another box, redirect is always a GET reuest so the URL string is all you have.
 
Ashish Agrawal
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Roland Barcia:
A forward stays on the server and is part of the same request. So you can store data as an attribute and forward. If you need to redirect to a Servlet that is part of another application on another box, redirect is always a GET reuest so the URL string is all you have.

Thats right...but as I mentioned in my post, I want to send objects and not just character data. Is there any other way like using URLConnection,etc.? If yes, how?
- Ashish Agrawal.
 
rick zorich
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is some quick and dirty JSP to demonstrate. Put both files in the same directory.
------------sender.jsp----------------------------------------
-------------------------------bouncer.jsp--------------------------
 
Ashish Agrawal
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Rick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic