java - Wrong Servlet path while using Servlet in form's action -


i trying send data login servlet using form in jsp. jsp , servlet in different folders. parent folder "mybay". in there folder named javaservlets , 1 named main_pages. in javaservlets there loginservlet.java , loginservlet.class. in main_pages there login.jsp. when submit username , password see tomcat stays in main_pages , does't in javaservlets folder. don't know if web.xml wrong.

http status 404 - /mybay/main_pages/loginservlet //here see path wrong. right path /mybay/javaservlets/loginservlet

can help?

here code:

login.jsp

             <form action="loginservlet" method="post">                 <p>                 <label id="upodeiksh">username</label>                 <br />                 <input type="text" name="username" id="koutaki" required/>                 </p>                 <br />                 <p>                 <label id="upodeiksh">password</label>                 <br />                 <input type="password" name="password" id="koutaki" required/>                 </p>                 <br />                 <input type="submit" name="upload" value="connect" id="submit_button"/>             </form> 

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="webapp_id" version="3.1">   <display-name>test_pages</display-name>   <welcome-file-list>     <welcome-file>index.html</welcome-file>     <welcome-file>index.htm</welcome-file>     <welcome-file>index.jsp</welcome-file>     <welcome-file>default.html</welcome-file>     <welcome-file>default.htm</welcome-file>     <welcome-file>default.jsp</welcome-file>   </welcome-file-list>    <servlet>     <servlet-name>loginservlet</servlet-name>       <servlet-class>javaservlets.loginservlet</servlet-class>     </servlet>     <servlet-mapping>       <servlet-name>loginservlet</servlet-name>       <url-pattern>/loginservlet</url-pattern>     </servlet-mapping>   </web-app> 

try add "/" infront of servletaction

<form action="/loginservlet" method="post"> 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -