--- Michael Tickle <[EMAIL PROTECTED]>
wrote:
 I am currently using apache to sent all requests to
> my servlet with
> 
> RewriteRule ^(.*)/(.*)
> http://win2k:9090/servlet/redirect?To=/$2 [R,L]
> 
> so my servlet gets the parameter To and knows what
> page the user requested.

That needs to have some more 'smarts' added to it.

> 
> I just tried
> response.sendRedirect("http://win2k/index.html");
> but that does not work with my rewrite rule as the
> page is redirected back
> to the servlet.  

Of course it won't!  Your rewrite rule is immediately
forwarding it 'back' to the servlet! :-)

1) request comes to apache
2) your rewrite rule sends it to tomcat servlet
3) tomcat servlet redirects it to apache
4) repeat at (2) !!!

You need to put some clue to the Rewrite Engine to
tell it that you don't want a URL to be rewritten
further.

I would suggest that you preprocess the url in your
servlet before you do the sendRedirect to embed some
clue such as rewriting it as:

http://win2k/index.html ->
http://win2k/index.html?DELEGATED=true

or whatever.  Next, modify your rewrite rule to have a
conditional:

RewriteCond  $0  !.*/DELEGATED.*
RewriteRule ^(.*)/(.*)
http://win2k:9090/servlet/redirect?To=/$2 [R,L]

This will make your rule skip any URL with the 'clue'
you've embedded.
Next, apply a rule to remove the 'clue'

RewriteCond $0 .*/DELEGATED.*
RewriteRule (.*)/DELEGATED(.*) $1$2

don't redirect this time or you'll just jump back into
the cycle.

Alternatively, you might just add a query string param
or set some other request info to act as your 'clue'.

Still another alternative is to simply run another
Apache server instance or virtual host that does NOT
apply your rewrite rule.  There are lots of
strategies.  Use your imagination.  :-)

>I was informed that this would not
> happen with
> RequestDispatcher.
>

??? RequestDispatcher will only forward or include
requests to be serviced in the same servlet engine. 
It can not redirect back to apache.
 
> The other option I can think of is to turn all the
> HTML pages in to JSP and
> have the JSP collect the information (request page,
> referring page, date,
> time, user agent and session id) and send it to a
> servlet - would that be a
> better way of doing it?
> 

It depends on your application.  I don't really have a
clear idea on what your high-level goal is here.

Good luck,

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