|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
problem with overlapping servlet mappingsSalut,
N R Platts wrote:
> 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?
Which version are you using? That should work...let me check.
Sorry for the delay.
A+
--JeanfrancoisI'm using grizzly-servlet-webserver-1.9.18a.jar downloaded today.Thanks. Nick.Apologies for the lack of appropriate formatting in this email - hotmail not being helpful.Did you know you can get Messenger on your mobile? Learn more. |
|
|
Re: problem with overlapping servlet mappingsHi Nick,
the example you provided doesn't work because of specifics how HTTP Mapper searches for appropriate ServletAdapter to process a request. Basically it never reaches "find Adapter by extension" point, because "find Adapter by prefix", which is executed before, always finds a match. If you'll change the code to this [1], it will work, and hope, work as you expected :) WBR, Alexey. [1] int port = 7070; GrizzlyWebServer ws = new GrizzlyWebServer(port); 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"}); 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[]{"/"}); ws.start(); On Oct 20, 2009, at 10:53 , N R Platts wrote:
|
| Free embeddable forum powered by Nabble | Forum Help |