Tomcat gives 404 when i call my servlet

java, jsp, servlets, tomcat

Solution

Change your `<form>` html to

<form action="urlCommandeServ" method="post">

When you're posting to `/urlCommandeServ` you're asking Tomcat (or your web server) to look for a web application named `urlCommandeServ` which isn't there and hence you get a 404.

Problem

I can't access to my servlet i call with a form. I checked the arborescence, web.xml and the form, but i can't see any problem. I use Eclipse with a "web dynamic project". There is my arborescence : My web.xml : ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>Z-ProjetJ2EE</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <servlet> <description></description> <servlet-name>CommandeServlet</servlet-name> <servlet-class>controleur.CommandeServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CommandeServlet</servlet-name> <url-pattern>/urlCommandeServ</url-pattern> </servlet-mapping> </web-app> ``` My form (i tried the complete url, but it didn't works) : ``` <form action="/urlCommandeServ" method="post"> ``` And my servlet : ``` protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String cat = request.getParameter("categorie"); Float prix = Float.parseFloat(request.getParameter("prix")); response.sendRedirect("CreerCommande?cat=" + cat+"&prix="+prix); ``` I didn't have any error in eclipse, and the log folder in tomcat is empty. Could you help me ? EDIT: There is my error : I agree for responses about my error on response.sendRedirect, but this is not the real subject of my error :) Even if i erase all of my code on doPost, i have this error, instead of a white page.

Original source