Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet call error: 404 servlet call not available

 
Abhijeet Garde
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

i have a question relating to servlet call.
I am using tomcat for my server.
I am calling a servlet from a html form action
as follows -

<form method="get" action="/myapplication/MyServlet">
<Input types -- >
<-- different input types here--->
< --------->

<input type="submit">
</form>


where myapplication is the name of my folder kept in webapps of Tomcat.

My servlet is kept in WEB-INF/classes, I have not used any package to keep the servlet in, it is directly inside classes.
My deployment discriptor ie web.xml is kept in WEB-INF.

the url mapping is -

<servlet-name>MyServlet</servlet-name>
<servlet-class>MyServlet</servlet-class>


<url-pattern>MyServlet</url-pattern>


but still when I press submit on my html page it gives 404 error and says /myapplication/MyServlet is not available.

please help.

Thanks in advance.
 
James Zhu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check the DOCBASE property of your application in the file of server.xml which is available in YOUR_TOMCAT_FOLDER/conf.
Without that the server can not find your application.

good luck (- -)V
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not used any package to keep the servlet in,

Experience suggests that this is a bad idea. Just do that little bit of extra effort, put ALL classes used with servlets in a package, and avoid many mysterious bugs.
Bill
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume these are exerpts from your deployment descrptor and that you've
got full <servlet> and <servlet-mapping> entries.



Try changing
<url-pattern>MyServlet</url-pattern>
to
<url-pattern>/MyServlet</url-pattern>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic