Reputation: 5474
My Servlet mapping looks like:
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
So my Servlet responds to requests such as http://bla.com/myservlet/bla/bla/bla
How can I make it respond to http://bla.com/bla/bla/bla
and get rid of the myservlet
portion of the path.
Further I want to strip the hello world servlet the the default welcome files that come with Jetty.
Thanks.
Note:
mod_rewrite
/ Apache -- I'm looking for a different solution.Upvotes: 1
Views: 1093
Reputation: 55886
If you are using Jetty installation. There are two ways to do it
root.war
, makes it's context root as /
create context.xml for your webapp
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Required minimal context configuration : -->
<!-- + contextPath -->
<!-- + war OR resourceBase -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/blawh.war</Set>
context.xml lives under $JETTY_HOME/contexts
. As you can see this directory already has context.xml for test.war. You can get decent idea of how your webapp's context.xml should look like by seeing the test.xml.
Once you are done with creating your own, go ahead and delete contexts/test.xml
, contexts/test.d
and webapps/test.war
. (just to clean test stuffs). This answers your second question too.
If you are using maven, just do this:
<plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <configuration> <webAppConfig> <contextPath>/</contextPath> </webAppConfig> <!-- snip -->
refer: Jetty/Howto/Deploy Web Applications
Upvotes: 3
Reputation: 5183
You can add multiple url patterns to map to same servlet
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/bla</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/bla/bla</url-pattern>
</servlet-mapping>
Upvotes: 1