I have some questions concerning Dispatchers with Guices servlet
extension.

I am working on introducing guice to a web application that uses the
servlets. There are a bunch of servlets that do not listen to any
specific path, because they are only called by their servlet name,
which is set within the web.xml:

--
        <servlet>
                <servlet-name>event</servlet-name>
                <servlet-class>net.our.application.some.ServletExample</servlet-
class>
                <load-on-startup>1</load-on-startup>
        </servlet>
--

Within the application they are addressed by calling
ServletContext#getNamedDispatcher(String). Since Guice does not use
the XML I did not find a documented way to assign servlet names, thus
not able to use named dispatchers (I tried
Key.get(MyServlet.class).toString() as the name, but wasn't
successfull).

So I guess my frist question would be: Is there any way to keep using
NamedDispatchers in Guice/Servlet applications?

My second question arose from not being able to work with dispatchers.
I tried to lookup the servlets directly from the injector by calling
injector.getInstance(MyServlet.class).service(request,response) but
got an exeption:

--
java.lang.IllegalStateException: ServletConfig has not been
initialized
        at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:
185) [servlet-api-2.5-20081211.jar:na]
        at net.sempr.services.endpoint.MyServlet.someMethod(MyServlet.java:
64) [classes/:na]
--

Is there a way to route a request to a servlet if said servlet is not
mapped to any path?

Thanks in advance,
Martin

-- 
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