Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hosting multiple web-apps in embedded jetty

 
aslam parveez
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a web-app hosted on embedded jetty. I would like to host the same web-app twice with different context-root so that I can access the app from both context-roots. I have my web-app context configured in jetty.xml like below, how can I have the same app added with a different context-root.
<Set name="handler">
<New class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/abc</Set>
<Set name="war">WebContent</Set>
<Get name="securityHandler">
<Set name="loginService">
<New class="DummyLoginService">
<Call name="start"/>
</New>
</Set>
</Get>
</New>
</Set>
 
aslam parveez
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found a way to have it done. For any one who is interested, please find below the jetty configuration snippet.

<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/abc</Set>
<Set name="war">WebContent</Set>
<Get name="securityHandler">
<Set name="loginService">
<New class="DummyLoginService">
<Call name="start"/>
</New>
</Set>
</Get>
</New>
</Item>
<Item>
<New class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/xyz</Set>
<Set name="war">../otherProj/WebContent</Set>
<Get name="securityHandler">
<Set name="loginService">
<New class="DummyLoginService">
<Call name="start"/>
</New>
</Set>
</Get>
</New>
</Item>
</Array>
</Set>
</New>
</Set>
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic