java - Error 505 on servlet request -


i'm trying make simple form error 500

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> 

the urlpatter set /login , form action login when try submit , 505 error, there no error on code , don't know whats problem.i've followed many tutorials , same error.

this error , servlet class not found

javax.servlet.servletexception: error instanciando clase de servlet [com.prueba1.loginservlet]     org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:478)     org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:80)     org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:650)     org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:342)     org.apache.coyote.http11.http11processor.service(http11processor.java:799)     org.apache.coyote.abstractprocessorlight.process(abstractprocessorlight.java:66)     org.apache.coyote.abstractprotocol$connectionhandler.process(abstractprotocol.java:868)     org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1457)     org.apache.tomcat.util.net.socketprocessorbase.run(socketprocessorbase.java:49)     java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1149)     java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:624)     org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     java.lang.thread.run(thread.java:748) causa raĆ­z  java.lang.classnotfoundexception: com.prueba1.loginservlet     org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderbase.java:1285)     org.apache.catalina.loader.webappclassloaderbase.loadclass(webappclassloaderbase.java:1119)     org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:478)     org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:80)     org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:650)     org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:342)     org.apache.coyote.http11.http11processor.service(http11processor.java:799)     org.apache.coyote.abstractprocessorlight.process(abstractprocessorlight.java:66)     org.apache.coyote.abstractprotocol$connectionhandler.process(abstractprotocol.java:868)     org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1457)     org.apache.tomcat.util.net.socketprocessorbase.run(socketprocessorbase.java:49)     java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1149)     java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:624)     org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     java.lang.thread.run(thread.java:748) 

project tree image:

enter image description here

just tried deploy , run code on own computer , worked well. make sure project structure valid, included loginservlet.java file project right , loginservlet.class file @ right directory after compilation. project stucture:

make sure class @ web-inf/classes

link screenshot

if can't solve problem, should show project structure after compilation. maybe can you, if screenshot not you. don't forget i'm using maven build project. structure may bit different.

if using maven add following lines dependencies block of pom.xml file:

`

<dependency>     <groupid>javax.servlet</groupid>     <artifactid>javax.servlet-api</artifactid>     <version>4.0.0</version>     <scope>provided</scope> </dependency> 

`

if not, try add following line before class declaration block:

@webservlet(name="any name want", urlpatterns="/login") 

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 -