Hi, Mike,
>From the spec :
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(java.lang.String path)
Returns a RequestDispatcher object that acts as a wrapper for the resource
located at the given path. A RequestDispatcher object can be used to forward
a request to the resource or to include the resource in a response. The
resource can be dynamic or static.
The pathname must begin with a "/" and is interpreted as relative to the
current context root. Use getContext to obtain a RequestDispatcher for
resources in foreign contexts. This method returns null if the
ServletContext cannot return a RequestDispatcher.
Parameters:
path - a String specifying the pathname to the resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource at the
specified path
See Also:
RequestDispatcher, getContext(java.lang.String)
The important sentence (relative to your example) is :
"The pathname must begin with a "/" and is interpreted as relative to the
current context root."
Pierre-Yves
-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de
Elaine Chong
Envoy� : dimanche 22 juillet 2001 21:54
� : [EMAIL PROTECTED]
Objet : FW: Redirect from one servlet to another?
One thing that you need to do is make an URL object from the string of the
URL, so you need to add a line: URL someURL = new
URL("http://newurl/servletname");
because I think the method getRequestDispatcher(Url url) takes a url object.
hth,
-Elaine
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Mike
Shoemaker
Sent: Sunday, July 22, 2001 1:16 PM
To: [EMAIL PROTECTED]
Subject: Redirect from one servlet to another?
Hello gang.
Anyone have any idea how to do this? I will paste a code snippet below that
Im working on and it doesn't seem to work.
I have a feeling that you can redirect to a different domain, is this true?
Any input would be appreciated.
// Do Redirect to page
try {
String url = "http://newurl/servletname;
RequestDispatcher rd =
this.getServletConfig().getServletContext().getRequestDispatcher(url);
rd.forward(req, res);
} catch(Exception e) {
e.printStackTrace();
}
TIA
Mike
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
___________________________________________________________________________
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
___________________________________________________________________________
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