Adding additional ServletContext in Pax Web

If you want to add certain special handlers for Jetty you just go ahead and
alter the jetty.xml file. Usually you just add the following peace of code

<Set name="handler">
 <New class="org.eclipse.jetty.server.handler.HandlerList">
  <Set name="handlers">
   <Array type="org.eclipse.jetty.server.Handler">
    <Item>
     <New class="org.eclipse.jetty.servlet.ServletContextHandler">
      <Set name="contextPath">/app</Set>
      <Set name="resourceBase">/path/to/your/share</Set>
      <Call name="addServlet">
       <Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
       <Arg>/</Arg>
      </Call>
     </New>
    </Item>
   </Array>
  </Set>
 </New>
</Set>

This won’t work together with Pax Web since Pax Web does have a specialized ServletContext Handler.

So Instead of defining a new one you just need to use the one that is already there. Please keep in mind
the master configuration of the Jetty Server is contained within the configuration of Pax Web.

The following shows how to achieve the same as above with Pax Web:

<Get name="handler">
 <Call name="addHandler">
  <Arg>
   <New class="org.eclipse.jetty.servlet.ServletContextHandler">
    <Set name="contextPath">/app</Set>
    <Set name="resourceBase">/path/to/your/share</Set>
    <Call name="addServlet">
     <Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
     <Arg>/</Arg>
    </Call>
   </New>
  </Arg>
 </Call>
</Get>


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.


*