Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resource not found

 
Hatim Khalifa
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the context path of your application.
 
Hatim Khalifa
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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\.....).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic