users@grizzly.java.net

problem with overlapping servlet mappings

From: N R Platts <splendidness_at_hotmail.com>
Date: Mon, 19 Oct 2009 13:15:35 +0100

Hello,

I'm trying to use an embedded grizzly servlet container with more than one servlet.
However the servlets have overlapping mappings. I want one servlet to handle all requests except those made to a url with a specific file extension ('.two' in this test case).

Here's my test code, the servlets just return their message so you can see which one you got :


// start webserver
int port = 8080;
GrizzlyWebServer ws = new GrizzlyWebServer(port);



ServletAdapter mysa1 = new ServletAdapter();
MyServlet myServlet1 = new MyServlet();
myServlet1.setMessage("Hello, I am One!");
mysa1.setServletInstance(myServlet1);
mysa1.setProperty(ServletAdapter.LOAD_ON_STARTUP, 1);
mysa1.setContextPath("/");
mysa1.setServletPath("/*");
ws.addGrizzlyAdapter(mysa1, new String[] {"/*"});

ServletAdapter mysa2 = new ServletAdapter();
MyServlet myServlet2 = new MyServlet();
myServlet2.setMessage("Hello, I am Two!");
mysa2.setServletInstance(myServlet2);
mysa2.setProperty(ServletAdapter.LOAD_ON_STARTUP, 1);
mysa2.setContextPath("/");
mysa2.setServletPath("/*.two");
ws.addGrizzlyAdapter(mysa2, new String[] {"/*.two"});


ws.start();



I've tried all sorts of combinations of context path, servlet path and 'alias' with varying results - normally one of the servlets taking all the requests. Is this achievable?

Thanks
Nick
                                               
_________________________________________________________________
Chat to your friends for free on selected mobiles
http://clk.atdmt.com/UKM/go/174426567/direct/01/