简体   繁体   中英

HttpServletRequest without Servlet Container

I'm using Jersey with Jetty (or Grizzly) and wiring up the server like so:

final ApplicationHandler handler = new ApplicationHandler(resourceConfig);
server = GrizzlyHttpServerFactory.createHttpServer(uri, handler);
server.start();

Using this method to start Jersey, I don't have access to HttpServletRequest as the factories are wired up in WebComponent. I can, however, inject javax.ws.rs.core.Request or org.glassfish.jersey.server.ContainerRequest, but I'm not sure how to get from there to HttpServletRequest.

The reason I need the servlet request and response objects is that I am using filter API's that depend on them. Am I wiring up Grizzly/Jetty wrong or do I need some sort of adapter factory for javax.ws.rs.core.Requests?

Thanks!

If you use Grizzly you may want to create a server via GrizzlyWebContainerFactory from grizzly2-servlet module. This way you should be able to inject HttpServletRequest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM