sendRedirect() essentially asks browser to go to new URL, so you don't ever
get the control because it's the browser who deals with 302. You may want to
consider RequestDispatcher().forward() instead. But if you are running two
VMs RequestDispatcher() may not work. Then you can post your request to
another servlet using URLConnection class (as someone has just discussed in
the mailing list) I am copying url from Christopher K. St. John's
[[EMAIL PROTECTED]] mail from the same mailing list.
http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html
Regards,
Chandra
The statements and opinions expressed here are my own and do not necessarily
represent those of Oracle Corporation.
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of G S
Sundar
Sent: Thursday, July 05, 2001 6:58 AM
To: [EMAIL PROTECTED]
Subject: facing problem while using sendRedirect !!!
Hello All,
I got problem while redirecting the URL to next servlet.
When I use sendRedirect from Servlet1:Port1 to Servlet2:Port2 if the
Servlet2 running at Port2 is down i'm getting "Page not fond" in IE
and "No response from Server" in Netscape. I want to display my own page
if the Servlet2 is not running in the Port2.
Here is my code which i've written for sendRedirect. But i'm not getting
my
page if the Servlet2 is not running in Port2.
Kindly tell me what i'm doing wrong in the following code or where i'm
wrong in the sendRedirect concept.
// This code exists in doGet method of Servlet1:port1
String param = req.getParameter("method");
if ( param == null )
{
res.getOutputStream().println("<html> <body> <p> Going to get the
param Value !!! </p></body> </html>");
try
{
servletContext.log("Going to redirect the URL !!!");
res.sendRedirect("http://localhost:port/servlet/SampleServlet2?method=SendLi
st");
}
catch(Exception ex)
{
servletContext.log("Exception Message : " + ex.getMessage());
}
res.getOutputStream().println("<html> <body> <p> Got the param
Value : NULL </p> </body> </html>");
servletContext.log("Param value null !!! ");
}
Regards
G S Sundaram
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html