users@grizzly.java.net

Re: Fwd: [Issue 453] [http-servlet] ServletAdapter doesn't support wildcard pattern in context

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 23 Feb 2009 10:28:58 -0500

Salut,

Survivant 00 wrote:
> is it me, or the bug is not completely fixed ?
>
> here what I'm doing.
>
> I recompile the trunk 1.9.7-snapshot
>
> and if I enter
>
> http://localhost/index.ftl it doesn't work, but if I enter
>
> http://localhost/*.ftl the servlet will be called
>
>
>
> here the output .. not really useful for me.. not enough verbose :)
>
>
> [main] Fri Feb 20 21:23:43 EST 2009 [FIN]
> com.sun.grizzly.http.SelectorThread initAlgorithm:Using Algorithm:
> com.sun.grizzly.http.algorithms.NoParsingAlgorithm
>
> [SelectorThread-80] Fri Feb 20 21:23:43 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:44 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:45 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:46 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:47 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:48 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:49 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:50 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:51 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:52 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:53 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:54 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:55 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:56 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:57 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:58 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:23:59 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:00 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:01 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:02 EST 2009 [FIN]
> com.sun.grizzly.Controller handleSelectedKeys:OP_ACCEPT on
> sun.nio.ch.SelectionKeyImpl_at_187aeca attachment: null
>
> [SelectorThread-80] Fri Feb 20 21:24:02 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:02 EST 2009 [FIN]
> com.sun.grizzly.Controller handleSelectedKeys:OP_READ on
> sun.nio.ch.SelectionKeyImpl_at_10385c1 attachment: 1235183042171
>
> [SelectorThread-80] Fri Feb 20 21:24:02 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:02 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [http80-WorkerThread(0)] Fri Feb 20 21:24:02 EST 2009 [LE PLUS FIN]
> com.sun.grizzly.http.SocketChannelOutputBuffer flushChannel:flushChannel
> isAsyncHttpWriteEnabled=false bb=java.nio.HeapByteBuffer[pos=0 lim=203
> cap=131072]
>
> [http80-WorkerThread(0)] Fri Feb 20 21:24:02 EST 2009 [LE PLUS FIN]
> com.sun.grizzly.http.SocketChannelOutputBuffer flushChannel:flushChannel
> isAsyncHttpWriteEnabled=false bb=java.nio.HeapByteBuffer[pos=0 lim=5
> cap=131072]
>
> [http80-WorkerThread(0)] Fri Feb 20 21:24:02 EST 2009 [FIN]
> com.sun.grizzly.Controller returnContext:returnContext() Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:02 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:03 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:04 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:05 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:06 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:07 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:08 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:09 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:10 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:11 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:12 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:13 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:14 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
> [SelectorThread-80] Fri Feb 20 21:24:15 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_13e8d89
>
> [SelectorThread-80] Fri Feb 20 21:24:16 EST 2009 [FIN]
> com.sun.grizzly.Controller pollContext:pollContext(..) Context :
> com.sun.grizzly.NIOContext_at_4f1d0d
>
>
> here the testcase.
> when I enter /index.ftl I would expect that the servlet will be called
> because the mapping is st /*.ftl
>
> public static void main(String[] args) {
> GrizzlyWebServer ws = new GrizzlyWebServer(80);
>
> try {
>
> ServletAdapter sa = new ServletAdapter();
> // sa.setContextPath("/");
>
> Servlet servlet =
> (Servlet)ClassLoaderUtil.load("test.HelloServlet");
> sa.setContextPath("/*.ftl");
> sa.setServletInstance(servlet);
>
> ws.addGrizzlyAdapter(sa, new String[]{});

You must do:

ws.addGrizzlyAdapter(sa, new String[]{"/*.ftl"});

or

ws.addGrizzlyAdapter(sa);

If you pass new String[]{}, it will be mapped to "/" and not with your
extension. Take a look at this unit test for more info:

https://grizzly.dev.java.net/nonav/xref-test/com/sun/grizzly/http/MapperTest.html

A+

-- Jeanfrancois




> ws.start();
> } catch(Exception e){
> e.printStackTrace();
> }
> }
>
>
>
>
>
>
>
> ---------- Forwarded message ----------
> From: *jfarcand* <jfarcand_at_dev.java.net <mailto:jfarcand_at_dev.java.net>>
> Date: 2009/2/19
> Subject: [Issue 453] [http-servlet] ServletAdapter doesn't support
> wildcard pattern in context
> To: survivant_at_dev.java.net <mailto:survivant_at_dev.java.net>
>
>
> https://grizzly.dev.java.net/issues/show_bug.cgi?id=453
>
>
>
> User jfarcand changed the following:
>
> What |Old value |New value
> ================================================================================
> Status|NEW |RESOLVED
> --------------------------------------------------------------------------------
> Resolution| |FIXED
> --------------------------------------------------------------------------------
>
>
>
>
> ------- Additional comments from jfarcand_at_dev.java.net
> <mailto:jfarcand_at_dev.java.net> Fri Feb 20 02:07:13 +0000 2009 -------
> Fixed, added a unit test (several :-))
>
> modules/http-servlet/src/test/java/com/sun/grizzly/http/MapperTest.java
>
> Sending
> modules/http-servlet/src/test/java/com/sun/grizzly/http/GrizzlyWebServerTest.java
> Adding
> modules/http-servlet/src/test/java/com/sun/grizzly/http/MapperTest.java
> Sending
> modules/utils/src/main/java/com/sun/grizzly/tcp/http11/GrizzlyAdapterChain.java
> Transmitting file data ...
> Committed revision 2511.
>