I run the Jetty server and try to register the servlet. This is how it works:

import com.crest.test.http.XmlParserServlet; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; public class JettyServer { public static void start(int port) throws Exception { Server server = new Server(port); ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS); context.setContextPath("/"); context.setResourceBase("src/main/resources/pages"); server.setHandler(context); // Add dump servlet context.addServlet(XmlParserServlet.class, "/xml"); // Add default servlet context.addServlet(DefaultServlet.class, "/"); server.start(); server.join(); } } 

But if I delete the line from DefaultServlet, I get Error 500: StackOverFlow. Here is the servlet itself:

 import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; public class XmlParserServlet extends DefaultServlet{ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.getRequestDispatcher("xml.jsp").forward(request, response); } } 

If that stakTreys also throw off, he just kilometer there. thanks for the help

    1 answer 1

    DefaultServlet is responsible for loading static content, so it is mapped to / . That is, all requests for which there is no maping come to it, including requests with *.jsp .


    request.getRequestDispatcher ("xml.jsp"). forward (request, response);

    You use a JSP request that must be processed by this servlet, otherwise the dispatcher will give an error that the file is not found or something like that, and then throw an error 500.