• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't run a servlet: HTTP Status 404 error. Folder structure and code included.  RSS feed

 
Alex Redwood
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm learning servlets and jsp and try to run my very first servlet. However when I try to access the servlet at http://localhost:8080/AppName/Lottery, but it doesn't work - I get a HTTP Status 404 - /AppName/ error. I can't figure out what's wrong. My servlet is inside a servlets package which is inside WEB-INF folder. I also have a web.xml file with name mapping. Any help is appreciated.




web.xml:



DiceRollServlet.java:



 
Dana Ucaed
Ranch Hand
Posts: 405
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recomand this link:

https://javabrains.io/courses/servlets_intro/.

 
Dana Ucaed
Ranch Hand
Posts: 405
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your web server run correctly?

 
Dana Ucaed
Ranch Hand
Posts: 405
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your web server runs at http://localhost:8080/ you can add your path to your servlet.


For example you must have the annotation in your class that extends HttpServlet.
@WebServlet(urlPatterns ={ "/AndaServlet"})

http://localhost:8080/AndaServlet it works for me.
 
Dana Ucaed
Ranch Hand
Posts: 405
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry...

 
Alex Redwood
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, thanks everyone. I figured out the cause of the problem - I didn't restart the server properly and didn't move .class files around.
 
Dana Ucaed
Ranch Hand
Posts: 405
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did you mean "didn't move .class files around"?

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!