--- Michael Tickle <[EMAIL PROTECTED]>
wrote:
> I am attempting to intercept all requests to a
> server so I can extract
> information from the header.  I would then like to
> pass the request on to
> the server for it to display the user the requested
> page.

Sounds straightforward.

> 
> I am led to believe that TomCat can not direct all
> requests to it on to a
> servlet - is this correct?  

Uh? What exactly are you trying to say here?  If you
are saying that tomcat can not be configured to send
every single request all to the same servlet, then I'm
not sure that's true.

Couldn't you setup servlet pattern-mapping like so:

    <servlet-mapping>
        <servlet-name>
            DelagatorServlet
        </servlet-name>
        <url-pattern>
            /
        </url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>
            DelagatorServlet
        </servlet-name>
        <url-pattern>
            *
        </url-pattern>
    </servlet-mapping>

You may need a couple of other patterns like "/*.*" or
"/*/*" as I'm not sure of the exact behavior of the
wild-card algorithm used in TC.

You may also want to define your own context for
"webapps/" to intercept activity there from going to
webapps/ROOT instead of to your application context.

I won't claim that this is simpler or better than just
using Apache's rewrite module.  It is recommended you
use apache anyway for serving static content, so it
may be simplest to just settup some RewriteRules to do
this (funnel all requests to a single servlet).

> I have installed apache and using mod rewrite all
> requests are forwarded on
> to my servlet.  The servlet the extracts the header
> information.  The
> problem then is showing the user the requested page.
>  Ideally I would just
> like to return the request to the server and let it
> deal with it. I am told
> the closest to this is RequestDispatcher.  However
> RequestDispatcher seems
> only to be able to use relative linking - this will
> not work for me as I
> want to go from
> http://win2k:9090/servlet/myservlet?To=/index.html
> to
> http://win2k/index.htm
> 
> Firstly is there a better way of doing what I am
> trying to do?

You want to use the HttpServletResponse.sendRedirect()
method instead of RequestDispatcher.forward().  The
forward() method only accesses urls reachable in the
current servlet engine thus they must be relative URLs
or 'absolute' relative to the current servlet context
path.  The sendRedirect() method is an actual HTTP
redirect that tells the browser to go somewhere else.

Keep in mind that neither a forward() or a
sendRedirect() will work once the response has been
committed, which can happen if you modify request
headers or write more output to the response than the
buffer size (8k I believe).

> 
> Secondly is there a similar feature to
> RequestDispatcher that can use full
> URLs not relative URIs?
> 

HttpServletResponse.sendRedirect()


> Thirdly has TomCat got any rewrite functionality (CF
> mod rewrite) since if I
> can not pass the request back to the apache domain I
> will have to somehow
> rewrite all the URLs in the tomcat domain.
> 

TOmcat has pretty minimal rewrite capability
(basically the servlet-naming tag above).  This sounds
like a prime candidate for an Interceptor for a future
version (ideally it work consistently with apache
mod_rewrite rules in effect) but is not trivial and
probably won't happen real soon.

However, as indicated above, you should be able to
solve your problem by using sendRedirect() to send the
requests back to apache (or wherever).

Cheers,

Mel


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to