Question

I have been scratching my head for some time on what seems to be a trivial problem. I have a webapp where the context on the webappcontext is defined as below. This code is to setup the embedded jetty webserver before starting it up. (I am not trying to change the context at runtime).

webAppContext.setContextPath("/MyApp");

If I then use the below code for my servlet context, everything works:

    servletContext.setContextPath("/");
    servletContext.addServlet(new ServletHolder(new LoginServlet()), "/LoginServlet");

But, now there are 2 different session IDs. One for "/" and one for "/MyApp".

If I change my servlet context code to the below, I am unable to find the url for it:

    servletContext.setContextPath("/MyApp");
    servletContext.addServlet(new ServletHolder(new LoginServlet()), "/LoginServlet");

I have tried urls such as, but they all give 404 not found:

 - http://localhost:8123/LoginServlet [which works in the first case]
 - http://localhost:8123/MyApp/LoginServlet
 - http://localhost:8123/MyApp/MyApp/LoginServlet

My servlet url is defined as

urlPatterns = { "/LoginServlet" }

I am using Eclipse for development and embedded Jetty for the web server. Any help or pointers will be appreciated. I am not an expert on this by any means and no amount of trolling the web has helped to this point.

Thanks in advance...

SOLVED Found the "trivial" issue. Had a blank session handler on the WebAppContext which was eating up all the requests sent to '/MyApp'.

Était-ce utile?

La solution

Found the issue!

Had an empty sessionHandler pointing to the webAppContext which was eating up all the requests. Once I removed it, everything worked as advertised.

Thanks to all responders.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top