I am using Jetty 9 in embedded mode (I have installed jetty in lib/jetty folder of my project and added all the jars in lib folder of jetty to build path). I am running my server using main method which has a resource handler to retrieve a jsp file on server start. This jsp file is a form with method post pointing to a servlet on action submit. I'm using dynamic web module 3.0 and servlet 3.0, the problem is i get 404 error when I click submit on jsp page. I made changes mentioned on jetty website like adding metadata-complete="false" to web app in web.xml and removed comments for annotations in start.ini of etc/jetty. I understand its a problem with servlet mapping, how to resolve this issue?
<Set name="configurationClasses">
<Array id="plusConfig" type="java.lang.String">
<Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
<Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
public static void main(String[] args) throws Exception
System.out.println("Initializing server...");
final Server server = new Server(8080);
System.out.println("Starting server...");
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setResourceBase(args.length == 2 ? args[1] : ".");
System.out.println(resource_handler.getResourceBase());
resource_handler.setWelcomeFiles(new String[] { "home.jsp" });
System.out.println("serving " + resource_handler.getBaseResource());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler()});
server.setHandler(handlers);
System.out.println("Failed to start server!");
System.out.println("Server running...");
catch (InterruptedException e)
System.out.println("Server interrupted!");
@WebServlet("/MainServlet")
public class MainServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public MainServlet() {
super();
// TODO Auto-generated constructor stub
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}