Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes Resource not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Resource not found" Watch "Resource not found" New topic
Author

Resource not found

Hatim Khalifa
Greenhorn

Joined: Mar 08, 2007
Posts: 5
Hi there...

It's my first time to develop web application using NetBeans which Tomcat comes bundeled with it. I am very frustrated though because I couldn't load my servlet when requested via an HTML form. I made sure that everything is in place and correct but Tomcat always generate a page that indicates that the resource "servlet" not found. Here is some of my code and config:

web.xml

<servlet>
<servlet-name>logger</servlet-name>
<servlet-class>Log</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>logger</servlet-name>
<url-pattern>/P</url-pattern>
</servlet-mapping>


HTML Form

<form method="POST" action="/P">
<input type="text" name="uname" size="20">
<input type="text" name="password" size="20"></p>
<input type="submit">
</form >




Although, NetBeans automatically includes Log.class in classes folder, Tomcat still cannot locate the resource. Please, guide me.
Thank you in advance


Hatim O. Khalifa<br />SCJP, SCJD
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Try taking the slash out of the form's action attribute:


If that doesn't work, post back with the URL that you're using to get to the HTML page with the form in it.
Also post the full path to your servlet (ex c:\tomcat\webapps\.....).
[ March 16, 2007: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60742
    
  65

What is the context path of your application.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Hatim Khalifa
Greenhorn

Joined: Mar 08, 2007
Posts: 5
Hi...

Well, the context path is /Book. However, I tried many url pattern variations and non of them worked. I tried things like:

/Book/P
/P
/Book/servlet/P
/servlet/P

But, I never tried linking to "P" alone. I will try it and then let you know what happen. Thank you for your help.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Ben Souther:
If that doesn't work, post back with the URL that you're using to get to the HTML page with the form in it.
Also post the full path to your servlet (ex c:\tomcat\webapps\.....).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Resource not found
 
Similar Threads
/test/GreetingServlet doesn't work
/test/GreetingServlet doesn't work
need help with declarative security
Problem in send redirect
servlet not being called from html