Programming Tips - How can I set the URI for my app?

Date: 2014dec22 Product: Jetty Q. How can I set the URI for my app? A. 1. The simple case. If you want:
http://localhost:8080/myapp/url1 http://localhost:8080/myapp/url2
Then you can see it in the WEB-INF/web.xml in your .war:
<servlet-mapping> <servlet-name>MyApp</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
url-pattern of /* means that your app will bet all URIs below it - ie
http://localhost:8080/myapp/* ^^
2. You don't want the app name in the path. In this case, you need to make a context file for your app. Which lives in <jetty-home>/contexts/myapp.xml If you send contextPath to /
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> ... <Set name="contextPath">/</Set> ... </Configure>
Then your apps URL will be
http://localhost:8080/*
(assuming you also send url-pattern to /*) This means your app will handle app URIs. So you'd better be ready for it.