• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot start servlet: message 'requested resource not available'

 
Laurence Met
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not understand why tomcat generates this error. I checked all the set up but could not see anything wrong.
The resource /Test/Test1.do should be available.

(note that I have the same issue with the Hands-On exercise of the Head First book)

Tomcat version = 5.5.20
Java 1.4

Here is my set up.

File Structure
==============
Test is my new application
tomcat/webapps/Test
In folder Test:
form.html
folder web-inf
In folder web-inf:
fold classes
In folder classes:
Test1.class

DD
==
<web-app...>
<servlet>
<servlet-name>Test1</servlet-name>
<servlet-class>Test1</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>Test1</servlet-name>
<url-patter>/Test1.do</url-pattern>
</servlet-mapping>

</web-app>

form.html
===========
<html><body>
<form method="POST" action="Test1.do">
<input type="SUBMIT">

</form>
</body></html>

Code Test1
==========
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Test1 extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("TEST");
}

}
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you able to run Tomcat's sample apps or jsps?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
folder web-inf

You mean WEB-INF in capital letters ?

<servlet-class>Test1</servlet-name>

You should put your classes into packages.

The resource /Test/Test1.do should be available.

Is this the exact message you receive ?
 
Laurence Met
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message is 'resource /Test/Test1.do not available'.
I already tried to define a package under the classes directory but it did not work either.
--> added the package foo under the classes directory
--> the class Test1 does now include a package statement
--> the web.xml is now defined as:
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>foo.Test1</servlet-class>
</servlet>
<servlet-mapping>
</servlet-name>Test</servlet-name>
<url-pattern>/Test1.do</url-pattern>
</servlet-mapping>

The class Test1 has been properly compiled and set in the folder foo.

I had a similar problem with the hands-on exercise (Head First chap 3) and it was solved by renaming the application in the webapps directory. It doesn not make much sense but it worked.
I tried the same with the Test application but it did not help.

The web-inf directory is defined as Web-inf. Would this be a problem?
Tomcat is starting the form.html properly.
The message appears when clicking on the "submit"button.

Any advice is welcome as I now really do not see what might be wrong.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The web-inf directory is defined as Web-inf

It must be all capital letters. Rename it WEB-INF. Also, I think you should keep the application name (the folder under webapps) in small letters.
[ November 01, 2007: Message edited by: Christophe Verre ]
 
Laurence Met
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. It it is now working properly.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!