Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet's web.xml

 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have created one servlet named firstServlet and put it in package com.mail
in web.xml i have written

<servlet>
<servlet-name>firstServlet</servlet-name>
<servlet-class>com.mail.firstServlet</servlet-class>
</servlet>

but when i run that , then it will give the error that page not found.

Please rectify me.

Thanks
Regards
Gaurav
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please also post your <servlet-mapping> ?
 
Nirav Patel
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Also, It's good practice to start java class with Capital letter. Like "FirstServlet". Only package names should start with small letter.

Just a code convention; good practice
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nirav Patel:
Only package names should start with small letter.


Its better and correct if we say, every word in a class name should start with a capital letter, according to naming convention. e.g. FirstServlet, LastFilter. . . etc.
 
Leslic Chan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should add this

<servlet-mapping>
<servlet-name>your class</servlet-name>
<url-pattern>/yourclassname</url-pattern>
</servlet-mapping>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic