Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Servlet redirection & POST method

Posted on 2000-03-15
8
Medium Priority
?
911 Views
Last Modified: 2013-11-24
I need to redirect one servlet I have, to another servlet situated in other machine using post method. Is it possible?

0
Comment
Question by:Lucsat
8 Comments
 

Expert Comment

by:WilliamCHall
ID: 2621034
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
 
LVL 3

Expert Comment

by:rjackman
ID: 2622429
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
 
LVL 16

Expert Comment

by:heyhey_
ID: 2622668
just send normal HTTP POST request.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Lucsat
ID: 2716114
heyhey... Read my question another time...
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 90 total points
ID: 2718718
http://www.javaworld.com/javaworld/javatips/jw-javatip34.html

Java Tip 34: POSTing via Java

another time ?
0
 

Author Comment

by:Lucsat
ID: 2721011
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
 
LVL 16

Expert Comment

by:heyhey_
ID: 2722569
thanks for the points :)
0
 

Author Comment

by:Lucsat
ID: 2722625
you're wellcome... ;)))))
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question