0

I am working on small web application using jsp, java, mysql and tomcat as web application server. My loginPage.jsp and index.jsp is in WebContent folder and I will collect user information username and password in loginPage.jsp and will use action to call a (loginservlet) servlet class that process (it does other stuff such as validating user and authorising) stuff and execute a line of code as show below

RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp");
dispatcher.forward(request, response);  

Things are ok until I see a 404 error after I entered username and password and hit submit button. It seems there is some confusion around servlet mapping or issue with where I keep my classes in project. right now i kept my servlet classes under /JavaResources/src/com.mycompany.xyz -- in xyz I have my class LoginServlet. Please help me with the issue on why I am getting 404 error.

<welcome-file-list>
<welcome-file>loginPage.jsp</welcome-file></welcome-file-list>   <servlet>  
<servlet-name>login</servlet-name><servlet-class>com.mycompany.xyz.LoginServlet</servlet-class>                 </servlet>   

<servlet-mapping>
<servlet-name>login</servlet-name>
<url-patt ern>/LoginServletPath</url-pattern>
</servlet-mapping>

After entering username and password and hit submit I see 404 page with below information. Instead of showing index.jsp I am getting 404 error, and I am not sure why.

type Status report

message /LoginServletPath

description The requested resource is not available.

MKod
  • 803
  • 5
  • 20
  • 33
  • Your question is ambiguous. To start, which URL do you see in address bar when 404 error is shown? Which resource that couldn't be found by the server is being mentioned in the 404 error message? – BalusC Apr 10 '16 at 19:21
  • I am seeing **http://localhost:8080/LoginServletPath**. Also what is on the page I have added in my original post. – MKod Apr 11 '16 at 04:54
  • 1
    @BalusC Your answer helped me thanks.**http://stackoverflow.com/questions/11731377/servlet-returns-http-status-404-the-requested-resource-servlet-is-not-availa** – MKod Apr 11 '16 at 06:05

0 Answers0