Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 919
  • Last Modified:

Servlet redirection & POST method

I need to redirect one servlet I have, to another servlet situated in other machine using post method. Is it possible?

0
Lucsat
Asked:
Lucsat
1 Solution
 
WilliamCHallCommented:
You can use the method:

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException

     Sends a temporary redirect response to the client using the specified redirect location URL.
     This method can accept relative URLs; the servlet container will       convert the relative URL to an absolute URL before sending the response to the client.


This will not however allow you to retrieve any variables from your first servlet in the second.  If you want to do that, you'd need to redirect to a jsp first and then to a servlet on another machine.  You can use this code in your servlet to redirect to a jsp.

req.setAttribute("items", item_vector);
getServletContext().getRequestDispatcher("/store/CheckOutJSPCart.jsp").forward(request, response);

In the local jsp file, you'll now be able to get to the variable items which contains item_vector from the servlet.
0
 
rjackmanCommented:
hi Lucsat

try these links:

http://webreview.com/pub/97/11/28/webdev/

http://www.servertec.com/products/iws/samples/servletchaining_src.html

http://java.sun.com/docs/books/tutorial/servlets/communication/other-servlets.html

but if u have to use the methods of the servlets those r situated on other servers then u have to use the RMI
but if u have to invoke other servlet then u can do it in post method by just
http://url request(url request -->IP address of the server/dir where servlet is stored/name of the servlet)

BestLuck
Rjackman
0
 
heyhey_Commented:
just send normal HTTP POST request.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LucsatAuthor Commented:
heyhey... Read my question another time...
0
 
heyhey_Commented:
http://www.javaworld.com/javaworld/javatips/jw-javatip34.html

Java Tip 34: POSTing via Java

another time ?
0
 
LucsatAuthor Commented:
Thank you for your help, heyhey. I don't know if finally I will use this method, or a pack of cookies, but it's very interesting...
0
 
heyhey_Commented:
thanks for the points :)
0
 
LucsatAuthor Commented:
you're wellcome... ;)))))
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now