You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Johnson, Garrett" <Jo...@cbsnews.com> on 2002/12/10 23:06:54 UTC

Tomcat/HTTPD Integration

Ladies and Gentlemen:

I've got 2 problems here:

1.  I've got a webapp sitting in the /webapps/ROOT directory, and I'd like
to be able to access it using Apache HTTPD instead of Tomcat's built-in
server.  However, the way it's set up now, simply typing in
http://www.myserver.com will bring up my index.jsp page.  How do I both
instruct Apache to serve up all requests for the root directory to Tomcat,
and how do I set up that alias to use MY index page?

2.  I'm currently instructing my servlet to handle erroneous form data by
sending the user back to the JSP with the form in it, with a flag embedded
within the request.  This let's me force them to resubmit, only with
reminder messages.  The code on the servlet side looks essentially like
this:

try
{
	updateDatabase( req ); //My own method
}
catch( SQLException e )
{
	req.setAttribute( "error", "true );
	ServletContext context = getServletContext();
	RequestDispatcher dispatcher = context.getRequestDispatcher(
"/start.jsp" );
	dispatcher.forward( req, res );
}

My question is, how do I get the URL on the client side to reflect the
forwarding?  Right now, the URL in the browser still indicates that they're
being handled by the servlet, while I want it to indicate that they've
returned to http://www.myserver.com/start.jsp.

Thanks in advance, kids...

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tomcat/HTTPD Integration

Posted by "Noel J. Bergman" <no...@devtech.com>.
Garrett,

> 1.  I've got a webapp sitting in the /webapps/ROOT directory, and I'd like
> to be able to access it using Apache HTTPD instead of Tomcat's built-in
> server.

Right.  You setup a connector, e.g., mod_jk, mod_jk2, mod_webapp.  Heck, I
even have a case where I have mod_proxy being used (don't ask why -- archaic
and going away, but it works)!

ref: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/connectors.html

> How do I both instruct Apache to serve up all requests for the root
> directory to Tomcat, and how do I set up that alias to use MY index
> page?

It is easier than you think.  Check the docs for your connector of choice.
The best documentation is probably for mod_jk.

If you want a laugh, here is how you do it with mod_rewrite/mod_proxy:

RewriteRule       ^/(.*)$   http://localhost:8080/$1     [P]
ProxyPassReverse  /         http://localhost:8080/

Again, *not* something I recommend.  [FWIW, you could use ProxyPass instead
of a rewrite rule, but there is a lot more going on that isn't shown above.]

> context.getRequestDispatcher("/start.jsp" );
> how do I get the URL on the client side to reflect the forwarding?

If you want the browser to go back to the start.jsp page, you send it there
with request.sendRedirect("/start.jsp"), not a RequestDispatcher.

> Thanks in advance, kids...

You're welcome gramps ...  ;-)

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>