• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Servlet not running in eclipse

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I just started basic servlet programming. i am using tomcat and eclipse indigo.

I have created a dynamic web project and added a new servlet with name NewServlet to the project and copied the servlet-api.jar to the lib in the WEB-INF folder. and created a an html file named c.html in the WEB-INF folder. I have edited the web.xml and made the welcome file value c.html. now when i run using run on server option, the c.html file is not getting displayed the url is http://localhost:8080/p3/NewServlet. what might be the mistake?

 
Master Rancher
Posts: 43045
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and created a an html file named c.html in the WEB-INF folder.


That's your problem - nothing that is inside WEB-INF will ever be served to the client directly. You need to move the file one directory level up (which is the root of web app's directory hierarchy).
 
sinatra roger
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry my mistake. It is inside the folder called web content. which now has META-INF,WEB-INF and NewFile.html
 
Ulf Dittmer
Master Rancher
Posts: 43045
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some more points:

and added a new servlet with name NewServlet to the project


http://localhost:8080/p3/NewServlet looks like it should run this servlet. The URL for having the welcome file served would be http://localhost:8080/p3/ (assuming that "p3" is somehow the name of the web app, which I have no idea about how that works in Eclipse).

and copied the servlet-api.jar to the lib in the WEB-INF folder


You should not do that. The Servlet API jar files are part of the servlet container; they must not be part of the web app as well.
reply
    Bookmark Topic Watch Topic
  • New Topic