users@grizzly.java.net

How does mapping work?

From: Andrea Gualano <andrea.gualano_at_imavis.com>
Date: Tue, 25 May 2010 13:04:29 +0200

Hello,
I am confused by how the mapping of GrizzlyAdapters works.

If I configure a web server like this:

         GrizzlyWebServer ws = new GrizzlyWebServer();

         ServletAdapter sa1 = new ServletAdapter();
         sa1.setServletInstance(new HelloWorldServlet());
         sa1.setContextPath("/hello");
         sa1.setServletPath("/world");
         ws.addGrizzlyAdapter(sa1, new String[]{"/hello/world/*"});

         ServletAdapter sa2 = new ServletAdapter();
         sa2.setServletInstance(new HelloMarsServlet());
         sa2.setContextPath("/hello");
         sa2.setServletPath("/mars");
         ws.addGrizzlyAdapter(sa2, new String[]{"/hello/mars/*"});

         ws.start();

Requests to the URLs /hello/world, /hello/world/moon, and so on are
served by HelloWorldServlet, as expected; requests to /hello/mars and
/hello/mars/phobos are also served by HelloMarsServlet as expected.
Request to / and /hi generate a 404 error, which is also expected.

However, a request for /hello/mercury is served by HelloWorldServlet or
HelloMarsServlet (randomly). Is this the expected behavior?
What should I do to only serve /hello/world/* and /hello/mars/* ?
Add an adapter for /? o for /hello/*?

All tests done on version 1.9.18-k.

Best regards,
Andrea

-- 
Andrea Gualano
ImaVis S.r.l.
email: andrea.gualano_at_imavis.com