File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes The requested resource (/review/HelloServlet) is not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "The requested resource (/review/HelloServlet) is not available" Watch "The requested resource (/review/HelloServlet) is not available" New topic
Author

The requested resource (/review/HelloServlet) is not available

Elsy Mena
Greenhorn

Joined: Mar 12, 2009
Posts: 8
Hello,

I am starting with servlets, jsp and Tomcat.

I am trying to complete a simple HelloServlet example.

I have Tomcat 6.0.18 and the relevant java. I can view the Tomcat main page from http://localhost:8080/

I created the directory structure:

C:\Tomcat\webapps\review\WEB-INF\classes

I have a web.xml file under the WEB-INF directory:


<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/review</url-pattern>
</servlet-mapping>

</web-app>





I have a HelloServlet.java file in the classes folder. I compiled it, and it worked fine.

However, when I try to view the page http://localhost:8080/review/HelloServlet it displays:

type Status report

message /review/HelloServlet

description The requested resource (/review/HelloServlet) is not available.


I don't know why, if I have my web.xml file with the descriptions needed to the servlet. May I did a mistake with the pathname? or there is something else missing?

Thank you very much.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
At quick glance I see two mistakes:
1) Classes ought to be placed in packages. There are circumstances wherein packageless servlets work, but you should never make your application dependent on that. That's a bad practice.
2) url-pattern is relative to the context root. So with this configuration your servlet is effectively to be accessed as http://localhost:8080/review/review

I'd to say, go through a decent JSP/Servlet tutorial or book. This all is namely fairly trivial.
Elsy Mena
Greenhorn

Joined: Mar 12, 2009
Posts: 8
Thank you very much Bauke, it worked with http://localhost:8080/review/review

I did not used a package because it was a little example, but I usually put my classes into packages. Do you know a good JSP/Servlet tutorial or book?


Thank you again.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Head First Servlets & JSP.
Elsy Mena
Greenhorn

Joined: Mar 12, 2009
Posts: 8
Thank you very much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The requested resource (/review/HelloServlet) is not available
 
Similar Threads
Configuring Tomcat...
unable to run servlet in tomcat
Unable to execute Servlet
Apache 2 and Tomcat 7 on Ubuntu 10.04 in VirtualBox 4.06xxx
HTTP Status 503 - This application is not currently available