John Cartwright wrote:
> "Craig R. McClanahan" wrote:
> >
> > John Cartwright wrote:
> >
> > > Hello All,
> > >
> > > I would like to find a way to have my servlet call an arbitrary URL
> > > (e.g. a cgi, servlet in another context, or even a URL on a different
> > > host). I don't seem to be able to do this with:
> > > rd = getServletContext().getRequestDispatcher(url);
> > >
> > > It will only let me forward to pages/servlets in the same context.
> > >
> > > I am using Tomcat 3.1, and would greatly appreciate any suggestions.
> > >
> >
> > You can use HttpServletResponse.sendRedirect() for this. It sends a "redirect"
> > response back to your browser, which will then link to the new URL that you pass as
> > an argument -- which can be any URL on any server.
> >
> > NOTE: You (obviously) won't be able to share any request attributes or session
> > attributes with the new URL since sendRedirect causes the browser to send a second
> > request, and sessions are scoped to the same context just like RequestDispatchers
> > are.
>
> Craig,
>
> thanks for your reply. Can I get the context of a webapp other than the
> one in which my servlet is running? If I'm using Apache to serve up
> JSP/Servlets from Tomcat, where does CGI come into the picture? Does it
> fall into any contect from Tomcat's perspective?
>
CGIs are not in the picture at all. By definition, a context (from Tomcat's
perspective,
or the perspective of any servlet container) consists only of servlets (plus things
that
get turned into servlets, like JSP pages, or executed by servlets) You will need to
use
sendRedirect() to transfer control to a CGI script.
>
> Thanks again for the help!
>
> -- john
>
Craig
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00): Sun Technical Briefing
Session T06 (24-Oct 14h00-15h00): Migrating Apache JServ
Applications to Tomcat
___________________________________________________________________________
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