Solved

Servlet redirection & POST method

Posted on 2000-03-15
8
889 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

Accepted Solution

by:
heyhey_ earned 30 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 49
use lov values 2 72
login form jsp example 2 50
running on tomcat not jboss eap 7.0 3 30
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…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

749 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