I have the following problem: I\'m trying to forward the request from the servlet to the jsp page, but I get an 404. When I´m accessing /sites/home.jsp directly, it loads th
This question comes up often enough, so I created an example project of using Embedded Jetty with JSP enabled.
https://github.com/jetty-project/embedded-jetty-jsp/
Load up this project into your favorite IDE.
Run the org.eclipse.jetty.demo.Main
class and then use your browser and open http://localhost:8080/
Quick Tour
src/main/java/org/eclipse/jetty/demo/Main.java contains the part that creates / configures / and starts the embedded server.
Pay particular attention to:
jspServletHolder()
org.eclipse.jetty.containerInitializers
needs to be setup for the JSP initializersServletContainerInitializersStarter
bean needs to be addedInstanceManager
reference needs to be addedjavax.servlet.context.tempdir
needs to be createdorg.apache.jasper.compiler.disablejsr199
to false
to use the standard JavaC compilergetUrlClassLoader()
defaultServletHolder()
src/main/java/com/acme/DateServlet.java is an example of how to forward to a JSP from a Servlet.
The DateServlet is mapped to path spec of /date/ in Main.java
So once you hit http://localhost:8080/date/
the request will hit the servlet, which in turn forwards to to /test/tag2.jsp