I want to add the handler to a servlet that is registered programmatically. Currently my servlet is a subclass of "javax.servlet.http.HttpServlet". This class is registered by using "httpService.registerServlet(alias, new MyServlet(args), null, null);" in the activation method of an OSGi component.
Optionally I would also like to know how to configure it using jetty.xml but this is not really important. Am Do., 18. Apr. 2019 um 13:43 Uhr schrieb Jean-Baptiste Onofré <[email protected]>: > > Yeah, I remember to have use it with previous Jetty version. > > If I understand correct, you want to add the handler programmatically ? > not via the jetty.xml right ? > > Regards > JB > > On 18/04/2019 13:38, Markus Rathgeb wrote: > > The GzipFilter is deprecated for Jetty >8 and does not contain any > > logic anymore: > > https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/GzipFilter.java > > > > Am Do., 18. Apr. 2019 um 13:33 Uhr schrieb Jean-Baptiste Onofré > > <[email protected]>: > >> > >> Did you try to add the GzipFilter ? > >> > >> You can register the GzipFilter as a Filter service (using the http > >> whiteboard pattern), providing mimeTypes and url-patterns as service > >> properties. > >> > >> Regards > >> JB > >> > >> On 18/04/2019 13:17, Markus Rathgeb wrote: > >>> To be clear: > >>> My whole setup is currently working WITHOUT the gzip compression > >>> (GzipHandler). > >>> I just want to know what I need to do to add Jetty's GzipHandler to > >>> programmatically registered servlets and to static content that is > >>> currently already added by the jetty.xml. > >>> > >>> Am Do., 18. Apr. 2019 um 12:33 Uhr schrieb Jean-Baptiste Onofré > >>> <[email protected]>: > >>>> > >>>> Hi Markus, > >>>> > >>>> Are you using jetty.xml in config property from org.ops4j.pax.web.cfg ? > >>>> Else your configuration won't be loaded in the Karaf Jetty connector. > >>>> > >>>> Regards > >>>> JB > >>>> > >>>> On 18/04/2019 11:36, Markus Rathgeb wrote: > >>>>> Hi, > >>>>> > >>>>> I would like to use gzip compression for > >>>>> * my servlets registered using the "registerServlet" method of > >>>>> "HttpService" > >>>>> * for a handler that provides static content of a directory added by > >>>>> jetty.xml > >>>>> > >>>>> The programmatic registered servlets are the most important ones. > >>>>> Would be nice if there is one global option to configure the default > >>>>> behavior and if it is still configurable per servlet. > >>>>> > >>>>> For the static content I am currently using that part of the jetty.xml > >>>>> === > >>>>> <Get name="handler"> > >>>>> <Call name="addHandler"> > >>>>> <Arg> > >>>>> <New class="org.eclipse.jetty.server.handler.ContextHandler"> > >>>>> <Set name="contextPath">/foo/static</Set> > >>>>> <Set name="handler"> > >>>>> <New > >>>>> class="org.eclipse.jetty.server.handler.ResourceHandler"> > >>>>> <Set name="resourceBase"><SystemProperty > >>>>> name="http.base.conf" />/html-foo</Set> > >>>>> <Set name="directoriesListed">false</Set> > >>>>> </New> > >>>>> </Set> > >>>>> </New> > >>>>> </Arg> > >>>>> </Call> > >>>>> <Call name="addHandler"> > >>>>> <Arg> > >>>>> <New class="org.eclipse.jetty.servlet.ServletContextHandler"> > >>>>> <Set name="contextPath">/bar/static</Set> > >>>>> <Set name="resourceBase"><SystemProperty > >>>>> name="http.base.conf" />/html-bar</Set> > >>>>> <Call name="addServlet"> > >>>>> <Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg> > >>>>> <Arg>/</Arg> > >>>>> <Call name="setInitParameter"> > >>>>> <Arg>dirAllowed</Arg> > >>>>> <Arg>false</Arg> > >>>>> </Call> > >>>>> </Call> > >>>>> </New> > >>>>> </Arg> > >>>>> </Call> > >>>>> </Get> > >>>>> === > >>>>> > >>>>> Can you give me some tips / information / solution? > >>>>> > >>>>> Best regards, > >>>>> Markus > >>>>> > >>>> > >>>> -- > >>>> Jean-Baptiste Onofré > >>>> [email protected] > >>>> http://blog.nanthrax.net > >>>> Talend - http://www.talend.com > >> > >> -- > >> Jean-Baptiste Onofré > >> [email protected] > >> http://blog.nanthrax.net > >> Talend - http://www.talend.com > > -- > Jean-Baptiste Onofré > [email protected] > http://blog.nanthrax.net > Talend - http://www.talend.com
