Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] How to include another web page in a page served by Jetty?

Jetty supports the Servlet API feature of RequestDispatcher.include, so one URI/resource can be included in another page.  The trick is how do you trigger than in the content that you are generating?    From the servlet, it should be easy enough to get a RequestDispatcher and call it directly.  If you want to do this from static content, then you will need to use something like JSP to process that content and allow dynamic components to be added.   For wordpress... either do it in wordpress... or do something very complex about intercepting responses and rewriting with the new content - possible but a lot of work.


On Sun, 29 Mar 2020 at 12:58, Alexander Farber <alexander.farber@xxxxxxxxx> wrote:

I am using Jetty 9.4.27.v20200227 -

1) in production server to server Wordpress/PHP and a Java servlet
2) in test server started locally at my Macbook to serve the Java servlet

I wonder if there is some kind of configuration statement for Jetty which would allow me to include other web pages inside the HTML web page files served by Jetty.

Then I would be able to emulate more functionality from the production server (which uses PHP to include other web pages/URLs) in my test server.

Thank you for any hints

PS: Below are the config files of my test server, they are pretty simple -

jetty.base/webapps/words.xml (to serve some static HTML pages):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
    <Set name="contextPath">/words</Set>
    <Set name="handler">
        <New class="org.eclipse.jetty.server.handler.ResourceHandler">
            <Set name="resourceBase"><SystemProperty name="jetty.base"/>/../words</Set>
            <Set name="directoriesListed">true</Set>

jetty.base/webapps/ws.xml (for the servlet and WebSockets):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/ws</Set>
    <Set name="war"><SystemProperty name="jetty.base"/>/../WebSockets/target/ws-servlet-0.1-SNAPSHOT.war</Set>

jetty-users mailing list
To unsubscribe from this list, visit


Back to the top