Hi Alexander,

You're getting yourself confused between the context path, and the servlet
path.

The context path is the path at which the webapp is deployed, such as "/"
or "/xyz".  Servlets are then deployed at paths relative to that context
path.  A request is matched first against the context paths of the webapps
deployed to find the 'best' (ie as defined by the servlet spec) match, and
then against the servlets deployed within the selected webapp for the
'best' match.

A webapp can only have a single context path, so your config file is wrong
there: choose either "/" or "/hello" but not both. So if you choose "/" as
the context path, and you have a servlet mapped to "/hello/*", then the url
http://localhost:8080/hello will route to that servlet.   If instead you
chose the context path "/hello" and still have a servlet mapped at
"/hello/*", then you would need to hit the url
http://localhost:8080/hello/hello  to route to it.

Also, the difference between the jetty maven plugin and the deployer from
the distribution if you don't provide an explicit context path is: the
jetty maven plugin chooses a context path that is the artifactId prefixed
with '/', whilst the deployer chooses the filename of the war (minus any
file extension) prefixed by '/'.

Jan

On 1 July 2016 at 00:04, Alexander Farber <[email protected]>
wrote:

> One more try -
>
> I have created the file $JETTY_BASE/webapps/hello.xml with the content:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "
> http://www.eclipse.org/jetty/configure_9_0.dtd";>
> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
>     <Set name="contextPath">/hello</Set>
>     <Set name="contextPath">/</Set>
>     <Set name="virtualHosts">
>             <Array type="java.lang.String">
>                     <Item>slova.de</Item>
>                     <Item>www.slova.de</Item>
>             </Array>
>     </Set>
>     <Set name="war"><SystemProperty
> name="jetty.base"/>/webapps/hello-world-0.1-SNAPSHOT.war</Set>
> </Configure>
>
> And see in Jetty logs, that the WAR-file is found and deployed:
>
> INFO:oejsh.ContextHandler:Scanner-0: Stopped o.e.j.w.WebAppContext@9720aef
> {/hello,null,UNAVAILABLE}{/hello-world-0.1-SNAPSHOT.war}
> INFO:oejw.StandardDescriptorProcessor:Scanner-0: NO JSP Support for /, did
> not find org.eclipse.jetty.jsp.JettyJspServlet
> INFO:oejsh.ContextHandler:Scanner-0: Started o.e.j.w.WebAppContext@2b82fd43
> {/,file:///tmp/jetty-127.0.0.1-8080-hello-world-0.1-SNAPSHOT.war-_-slova.de-2204701430203830577.dir/webapp/,AVAILABLE,
> slova.de}{/hello-world-0.1-SNAPSHOT.war}
>
> However browsing to the following pages results in "404 page" displayed by
> Wordpress:
>
> http://slova.de/hello/
> http://slova.de/hello/hello/
>
> I have put the "hello" project at
> https://github.com/afarber/jetty-newbie/tree/master/JettyMavenHelloWarApp
>
> Regards
> Alex
>
> On Thu, Jun 30, 2016 at 1:53 PM, Alexander Farber <
>> [email protected]> wrote:
>>
>>> But my real question is what would be please the best way to specify a
>>> path like "/hello" (or "/ws") when developing a WAR-file?
>>>
>>> I would like to develop my project in NetBeans and copy the produced
>>> WAR-file to the Linux-server (and maybe try to connect to it remotely as
>>> described at
>>> https://www.eclipse.org/jetty/documentation/9.3.x/enable-remote-debugging.html
>>> )
>>>
>>> I have read
>>> https://www.eclipse.org/jetty/documentation/9.3.x/configuring-contexts.html#setting-context-path
>>> but I am still not sure, what would be the best method for specifying
>>> context (like "/hello" or "/ws") and vritual host for my WAR-file...
>>>
>>>
>>>
>>
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>



-- 
Jan Bartel <[email protected]>
www.webtide.com
*Expert assistance from the creators of Jetty and CometD*
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to