Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP Status 404 Error in basic login form  RSS feed

 
K. Karacakaya
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,
I'm trying to learn java by making a login page using java, servlet, javascript, html and mysql.
I can login with username and password, I can get all the information from database in the edit page. However, when I edit and click on "Submit" in EditPage.jsp, it gives HTTP Status 404. Same screen appears when I click on "Sign Up" from first page (NewFile.jsp) and click on "Submit" button after filling up user information.

I am posting all my code here but probably important ones are: EditPage.jsp, Edit.java, EditDetails.java, UpdateUser.java and for Sign Up SignUpPage.jsp and Registration.java.

Firstly here are my error message and ss from my project explorer:




Here is my code:

LoginServlet.java


Edit.java


Registration.java


glassfish-web.xml
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is mapped to /Edit? Two of the servlets are mapped to something else, and one servlet isn't mapped to anything AFAICT.

I took the liberty of deleting a bunch of stuff that has no bearing on a 404.
 
K. Karacakaya
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 3 form actions. One of them is in NewFile.jsp: <form action = "LoginServlet" method = "post"> This one is for submitting username and password. One of them is in SignUpPage.jsp: <form action="Registration" method="post"> This one is submitting register page. And the last one is in EditPage.jsp: <form name="frm1" action= "Edit" method = "post"> to submit edited information.
It looks like 1st one is working and rest are not working and I couldn't figure out why. BTW I'm new in Java web.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... LoginServlet ... Registration ... Edit...

It looks like 1st one is working and rest are not working


The first one is mapped (in LoginServlet.java), the other two are not. The URL you need to use is determined by the "@WebServlet" annotation. There is no such annotation in Registration.java , and the one in Edit.java points to a different URL (/UpdateCustomerServlet).

As a general practice I recommend that you remove the word "servlet" from any mappings, for example you might have "Register", "Login" and "Edit".
 
K. Karacakaya
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks much Ulf. Status 404 problem is solved
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Ulf.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!