Alfonso Urdaneta wrote:
> [snip]
> Works great, expect that I'm also intercepting cgi-bin requests, which
> is not neccessarily a good thing. I wondering - is it possible to pass
> that reqest back to the server ? That way I could grab the request and
> deny it if there is not a good session going on, or return it to the
> main server for processing if there is a session.
>
> Now I am aware that servlets are meant to replace cgi-bin but our
> product is meant to be bolted on to existing sites. If the customer has
> to go through and replace all his cgi scripts with servlets, then we are
> a non-starter.
>
> At first I was planning to have my servlet simply execute the cgi
> script, but I have been told that this is not as easy as it would seem.
> I thought that all I had to do was write some environment variables, and
> then then open an input and output stream, but I guess that it is a
> little more complicated than that.
>
> So, is such a thing possible ?
>
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?
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.
This approach also means that your code doesn't break when the webmaster
changes where the "/cgi-bin" directory is mapped to, because you are still
passing on a valid URL.
>
> 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