users@glassfish.java.net

Re: Dynamically Map Servlets (programmatically, without web.xml)

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Mon, 04 May 2009 15:40:48 -0700

On 05/ 4/09 01:13 PM, glassfish_at_javadesktop.org wrote:
> Does anybody know if there is a way to programmatically inject a servlet-mapping into the glassfish container at runtime? i.e. I can map servlets in web.xml, but I'm wondering if there is a programmatic way.
>
> Or, alternatively, does anybody know where in the glassfish source the web.xml parsing is done? From there, I could work my way to where glassfish registers servlet mappings and see if I could inject a few more without breaking anything using reflection.
>

Servlet 3.0 supports this in a portable fashion, via the new
ServletContext#add[Servlet|Filter]
methods and the [Servlet|Filter]Registration objects they return.

I've attached a sample ServletContextListener implementation that
demonstrates the use of the
new APIs, which are fully implemented in GlassFish v3.

Hope this helps.

Jan

> Thanks!
> [Message sent by forum member 'rwillie6' (rwillie6)]
>
> http://forums.java.net/jive/thread.jspa?messageID=344922
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>