0

Is there a way to read session from ResourceHandler like you can do it from ServletContextHandler? Something like this: request.getSession(true).setAttribute("test", test)

1 Answers1

1

The javax.servlet.http.HttpSession is only present on contexts that belong to a javax.servlet.ServletContext.

So no, you cannot access it from a ResourceHandler.

Why do you need to do this for a static resource, and cannot just use the more complete static file serving feature-set of the DefaultServlet found within a ServletContextHandler?

And yes, you can have it serve static resources from alternate locations.

Serving static files from alternate path in embedded Jetty

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • because we use extension of ResourceHandler for access handling. And ServletContextHandler doesn't allow to override the handle method. – Shamannn Shamannn Apr 17 '20 at 16:07
  • 1
    `ServletContextHandler` has it's own access controls built-in, and you can easily extend from `DefaultServlet.service()` to accomplish the same end goal. – Joakim Erdfelt Apr 17 '20 at 16:57