Alfonso Urdaneta wrote:
> "Craig R. McClanahan" wrote:
>
> > It's not clear from your description how it is really set up, but why can't
> > you forward CGI requests back to the server the same way you forward file
> > requests? Or are you actually serving the files yourself?
>
> I do a get context, and then getservlet("file") and make it do the work
> for me. I know that this has been deprecated, but the new sdk does not
> give me anything that I really need ( AFAIK ) so I'm holding off on
> upgrading.
>
My understanding is that some servlet engines allow you to get a context that maps
to the web server's space like this:
ServletContext context = getServletContext().getContext("/");
and, when you ask this context for a RequestDispatcher, it maps to the web servers
URLs. This would let you connect to anything that would normally be served
directly. How it is actually implemented underneath (either via URLConnection or
private linkages back to the web server) is transparent to your code, but may also
have performance implications.
I also understand that this behavior might well be formalized in a future version
of the servlet API so that it becomes standard. In the meantime, you will need to
check out the individual servlet engines. Don't forget to make sure it deals with
POST requests correctly, and doesn't try to translate them into GET requests.
>
> > If your app is grabbing the incoming requests before the web server ever sees
> > them, one easy approach would be to build a java.net.URLConnection and talk to
> > the web server itself (on a private port that is blocked from external
> > access), as if you were the client. There are some simple examples of this in
> > the Java Language Tutorial on Javasoft's web site. You will probably need
> > something a little more complex to deal with POST requests, and including all
> > the headers you received from the client, but it is certainly possible.
>
> Yeah, that's what I figured I was going to have to do.
>
> It does not sound like it would be too painful, and it seems that I
> don't have a choice based on what Costin wrote in another reply -
> apparently he tried to use RD to pass stuff to cgi and it did not work
> right.
>
One of the common confusions about request dispatchers is that the path you give
them is LOCAL to a servlet context, not GLOBAL to the web server's URI namespace.
The special getContext() trick deals with that issue, if it is supported by your
servlet engine.
>
> Alfonso.
>
Craig McClanahan
___________________________________________________________________________
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