Solved

Servlet redirection & POST method

Posted on 2000-03-15
8
881 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
Comment Utility
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
Comment Utility
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_
Comment Utility
just send normal HTTP POST request.
0
 

Author Comment

by:Lucsat
Comment Utility
heyhey... Read my question another time...
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 16

Accepted Solution

by:
heyhey_ earned 30 total points
Comment Utility
http://www.javaworld.com/javaworld/javatips/jw-javatip34.html

Java Tip 34: POSTing via Java

another time ?
0
 

Author Comment

by:Lucsat
Comment Utility
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_
Comment Utility
thanks for the points :)
0
 

Author Comment

by:Lucsat
Comment Utility
you're wellcome... ;)))))
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now