http status code 404 - Error 404 on very simple java servlet -


i'm trying make simple form error 500 code returb apparently no errors.

index.php

<html> <body>     <form action="login">         <input type="text" name="nombre"></input>         <input type="submit" value="enviar"></input>     </form> </body> </html> 

loginservlet.java

package com.prueba1;  import java.io.ioexception; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse;  /**  * servlet implementation class loginservlet  */ public class loginservlet extends httpservlet {     private static final long serialversionuid = 1l;      /**      * default constructor.       */     public loginservlet() {         // todo auto-generated constructor stub     }      /**      * @see httpservlet#doget(httpservletrequest request, httpservletresponse response)      */     protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         // todo auto-generated method stub         response.getwriter().append("served at: ").append(request.getcontextpath());     }      /**      * @see httpservlet#dopost(httpservletrequest request, httpservletresponse response)      */     protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         // todo auto-generated method stub         doget(request, response);     }  } 

web.xml

<!doctype web-app public  "-//sun microsystems, inc.//dtd web application 2.3//en"  "http://java.sun.com/dtd/web-app_2_3.dtd" >  <web-app>   <display-name>archetype created web application</display-name>   <servlet>     <servlet-name>loginservlet</servlet-name>     <display-name>loginservlet</display-name>     <description></description>     <servlet-class>com.prueba1.loginservlet</servlet-class>   </servlet>   <servlet-mapping>     <servlet-name>loginservlet</servlet-name>     <url-pattern>/login</url-pattern>   </servlet-mapping> </web-app> 

when try submit , 404 error, there no error on code , don't know whats problem.

404 error comes when page not found

you getting 404 error because form action not correct. submitting form login have submit form loginservlet

try this

<html>  <body>  <form action="loginservlet">  <input type="text" name="nombre"></input>  <input type="submit" value="enviar"></input>  </form>  </body>  </html> 

thank you


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -