On Fri, Nov 19, 2010 at 2:42 AM, decitrig <[email protected]> wrote:
>> serveRegex("^((?!^/index\\.html$|^/test\\.html$).)*$").with(MyServlet.class )
>
> Aesthetically, I think I prefer having a url prefix for the guice
> filter. Neither seem to be ideal; I would love something like
>
> serveStatic("/index.html").with(new File("war/static/index.html"))
>
> I'm no servlet expert, but it seems like this could be implemented in
> the guice servlet by having a map of urls to files, and maybe a
> another servlet that just spits out the file contents when asked for.

AFAIR the servlet request handling sequence works the way, that after
all the filters, if no servlet mapping is resolved, the request goes
to so called default servlet (mapped to /*). Every servlet container
has own implementation of this. Here is one for jetty:

http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java

It would be possibe to do something like:
bind(DefaultServlet.class).in(Singleton.class);
serve("/index.html").with(DefaultServlet.class);

,however AFAIR there are some drawbacks of mapping DefaultServlet to
something other than /*, at least on some servlet containers - the
path before * could be excluded from webapp context relative file
path. In some servlet containers the default servlet is declared with
name 'default' and you can use own mapping to this servlet in web.xml,
however it does not seem to be portable. The solution I proposed looks
ugly - I know it, however it seems to be portable, as long as we can
count on different default servlet implementations. :)

-- 
"Meaning is differential not referential"

kazik 'morisil' pogoda
http://www.xemantic.com/ http://blog.xemantic.com/

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to