• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in running my servlet project (404 error)

 
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a project name servlet_project and 2 servlet named serv and serv2 (sorry for stupid names).
When I am trying to run this project, I am getting 404 error.But if I run both the servlets independently, they both running fine. ServletContextListener also running fine. Also if I write url http://localhost:8080/servlet_project/startpage then it works fine and execute serv.java
But the problem is in running the whole project. I know their something very little I am missing, (may be my project is not getting what to show the first page )
could someone please tell me that wrong thing I am doing .

The web.xml file is :


The servlet I am using in this project :


Here is the picture which describing the error and my class hierarchy :
servlet-problem.png
[Thumbnail for servlet-problem.png]
When I am running my project, I am getting this
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you worked through the list in the ServletsFaq for 404 errors?
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Puspender Tanwar wrote:Also if I write url http://localhost:8080/servlet_project/startpage then it works fine and execute serv.java


So that means the setup of your servlet is correct, otherwise that url would not work.

You should probably define a welcome file as described here. Adding the following code snippet to the web.cml file should execute the servlet servlet.

Hope it helps!
Kind regards,
Roel
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roel De Nijs wrote: Adding the following code snippet to the web.cml file should execute the servlet servlet.


I just ran the solution you told and that just worked fine .
Thankyou so much Roel
So, Welcome file is must ??
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Puspender Tanwar wrote:I just ran the solution you told and that just worked fine .


Glad to hear my provided solution did the trick! for me

Puspender Tanwar wrote:So, Welcome file is must ??


No, it's definitely not a must. Otherwise your project would not have run and a runtime exception would be thrown at startup. If you don't define a welcome file, a default welcome file will be used. Often (or maybe even always), that's index.html. Because you want another welcome file to be used in your project, you must define a welcome file list.

Hope it helps!
Kind regards,
Roel
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok
Thanks One again
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic