You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Scott Deerwester <sc...@HK.Super.NET> on 2000/03/01 02:35:33 UTC

Servlet as "http://mysite.com/"???

I have a Tomcat servlet that acts as a filtering proxy server for a
particular site. It performs some minor scrubbing on the content from
the real Web site, which it forwards to the client. The problem is that
it needs to respond to and pass on ANY valid URL on the real site...
AFAIK, a Tomcat servlet must be referred to as


http://mysite.com/myservlet/servlet/aservlet/other/info

either in the standalone server or when hooked up to Apache via JServ,
where /other/info is available to the servlet in the
HttpServletRequest.getRequestURI(). But what I need is for:

                       http://mysite.com/other/info

to call the servlet directly with "/other/info" passed along in
getRequestURI(). Defining a VirtualHost in Apache's httpd.conf doesn't
help, because the DocumentRoot is a physical file location, not a
logical location. So I can't do something like:

                       <VirtualHost>
                         ServerName = mysite.com
                         DocumentRoot = /myservlet/servlet/aservlet
                       </VirtualHost>

The problem is, the client will be given absolute URL's on the real host
which, for technical reasons, the servlet will not be able to intercept
and modify (the content isn't HTML). So I have the following:

Client:    http://mysite.com/myservlet/servlet/aservlet/aPage ->
Servlet:  http://realsite.com/aPage ->
Server:   "...; var=/nutherPage; url=http:$var; ..." ->
Servlet:  "...; var=/nutherpage; url=http:$var; ..." ->
Client:    http://mysite.com/nutherPage ->
Servlet:  ???

and, of course, "http://mysite.com/nutherPage" doesn't exist. The only
obvious solution seems to me that the servlet be addressable as

                       http://mysite.com/

which I don't know how to do. I've tried putzing with virtual hosts in
Apache, and with the servlet and Tomcat server configurations, but I'm
stumped. Can anybody help?

advTHANKSance!



Re: Servlet as "http://mysite.com/"???

Posted by Bradley McLean <br...@ne.mediaone.net>.
* Scott Deerwester (scott@HK.Super.NET) [000301 21:43]:
>
> AFAIK, a Tomcat servlet must be referred to as
> 
> http://mysite.com/myservlet/servlet/aservlet/other/info
> 
> either in the standalone server or when hooked up to Apache via JServ,
> where /other/info is available to the servlet in the
> HttpServletRequest.getRequestURI(). But what I need is for:
> 
>                        http://mysite.com/other/info
> 
> to call the servlet directly with "/other/info" passed along in
> getRequestURI(). Defining a VirtualHost in Apache's httpd.conf doesn't
> help, because the DocumentRoot is a physical file location, not a
>...

What about an apache rewrite rule from
http://mysite.com/other/info  -> 
http://mysite.com/myservlet/servlet/aservlet/other/info ?