How do I remove the root element of my Jetty webapp url?

Answered

I am running a Java webapp (let's call it mywebapp).

Currently I access my page in this webapp by pointing locally to:

http://localhost:9000/mywebapp/mystuff

However, I need to access it using:

http://localhost:9000/mystuff

How can I do this? I've tried messing with some confs, but to no avail...

This is my current root.xml:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <Set name="contextPath">/root</Set>
    <Set name="war">
        <SystemProperty name="app.webapps.path"/>/mywebapp.war
    </Set>
</Configure>

Also tried:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <Set name="contextPath">/</Set>
    <Set name="war">
        <SystemProperty name="app.webapps.path"/>/mywebapp.war
    </Set>
</Configure>

I'm using Maven - not sure if that may be making the difference.

Thanks!

 

mymilestonecard

4 comments
Comment actions Permalink

You can change deployment options in run configuration: 

0
Comment actions Permalink

In order to set your context path to "/" you'll want to use a Context deployment. Note: You MUST specify a context path string for path spec mapping reasons. An empty context path string "" is only valid as a mapping result from requests to the context root. See Section 12.2 of the servlet spec)

In Jetty 7.x, the context path assignment is handled by the AppProviders assigned to the DeploymentManager.

By default, on the Jetty Distribution, both the WebAppProvider and ContextProvider are enabled. This is important to know later, as it will influence your decisions on where to put the mywebapp.war file.

See the ${jetty.home}/start.ini file, and you'll see that it contains both the references to etc/jetty-webapps.xml and etc/jetty-contexts.xml

WebAppProvider's role is to pay attention to the ${jetty.home}/webapps/ directory for any deployable applications (such as *.war) and deploy them onto a context of the same name as the filename. In other words ${jetty.home}/webapps/MyApp-2.4.war is deployed into the context "/MyApp-2.4". There is also the special "root.war" reserved word that will deploy into the context "/". While this is the easiest deployment mechanism, it sacrifices control over the deployment specifics. Mymilestonecard

0
Comment actions Permalink

I'm using Maven - not sure if that may be making the difference rgrhcl

Thanks!

0
Comment actions Permalink

not sure if that may be making the difference aka.ms/remoteconnect

0

Please sign in to leave a comment.