[undertow-dev] How to Access ServletContext?

Stuart Douglas sdouglas at redhat.com
Mon Aug 10 02:06:28 EDT 2015



----- Original Message -----
> From: "Ari King" <ari.brandeis.king at gmail.com>
> To: undertow-dev at lists.jboss.org
> Sent: Saturday, 8 August, 2015 7:53:00 AM
> Subject: [undertow-dev] How to Access ServletContext?
> 
> I've embedded Undertow into a Resteasy (JAX-RS) app. One of the libraries I'm
> using requires a servlet context attribute to be set. How can/should I go
> about doing so?
> 
> If I should use a ServletExtension, to clarify, I need to create a file named
> " io.undertow.servlet.ServletExtension" and put it in the
> "META-INF/services/ " directory?
> 
> Within the above mentioned file do I need to provide the fully qualified name
> of the implementation class?

Yes, although there are some other options:

- You can use io.undertow.servlet.api.DeploymentInfo#addServletExtension to create the extension yourself
- You can also use a ServletContainerInitializer or ServletContextListener instead of a ServletExtension
- In your embedding code you can call DeploymentManager.getDeployment().getServletContext()

Stuart


> 
> Thanks.
> 
> Best,
> Ari
> 
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev


More information about the undertow-dev mailing list