• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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

 
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:



 
Ranch Hand
Posts: 444
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: 444
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: 444
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: 444
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: 444
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!