I wrote a MVC Servlet + JSP web application and deployed in Apache+Tomcat. I don't call JSP directly, but I use them as view and I call them from the Servlets.

To make it visible in a virtual host, I mapped it using JkMount:

JkMount /MyApplication/* ajp13_worker

However now to access MyApplication I've to write URLs as


I would like to be able to call MyServlet from the root of my virtualhost such as in:


How do I do this?


How about:

RewriteEngine On
RewriteRule ^(/MyServlet.*) /MyApplication$1 [passthrough]

The passthrough will allow mod_jk to take the request after being processed by mod_rewrite

  • thank you, this works, I added a RewriteRule to get to the first servlet: "RewriteRule ^/$ /index [R]", however, when in a servlet I call "response.sendRedirect("my-servlet");", it adds the /MyApplication prefix again. Maybe I should call "response.sendRedirect("/my-servlet"); – stivlo Feb 1 '11 at 10:00
  • I don't know about response.sendRedirect but I suspect it returns a relative URI. Tomcat doesn't know about the RewriteRule. Another option is to deploy your application as ROOT.war with "JkMount /* ajp13_worker" in the apache config. Tomcat will still redirect requests to other applications, but will recognize your servlets in the "/" path. – dialt0ne Feb 1 '11 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.