GeeCON Prague 2014*
The moose likes Servlets and the fly likes The requested resource () is not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "The requested resource () is not available" Watch "The requested resource () is not available" New topic
Author

The requested resource () is not available

roshan laddu
Greenhorn

Joined: Aug 27, 2008
Posts: 9
Following appears when i open html in browser by --http://localhost/servlets/ThreeParamsForm.html
---------------------------------------------
HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/6.0.18
-----------------------------------------------------------------
please help me
----------------------------------------------------------------
C:\jdk1.6.0_03
C:\jre1.6.0_03
C:\Tomcat6.0\webapps\servlets
C:\Tomcat6.0\webapps\servlets\ThreeParamsForm.html
C:\Tomcat6.0\webapps\servlets\WEB-INF\web.xml
C:\Tomcat6.0\webapps\servlets\WEB-INF\classes\ThreeParams.class
----------------------------------------------------------------
ThreeParams.java:
*****************
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Simple servlet that reads three parameters from the
* form data.
*/
public class ThreeParams extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Reading Three Request Parameters";
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +
"<UL>\n" +
" <LI><B>param1</B>: "
+ request.getParameter("param1") + "\n" +
" <LI><B>param2</B>: "
+ request.getParameter("param2") + "\n" +
" <LI><B>param3</B>: "
+ request.getParameter("param3") + "\n" +
"</UL>\n" +
"</BODY></HTML>");
}
}
---------------------------------------------------------
ThreeParamsForm.html:
*********************
<HTML>
<HEAD>
<TITLE>Collecting Three Parameters</TITLE>
</HEAD>
<BODY BGCOLOR="#FDF5E6">
<H1 ALIGN="CENTER">Collecting Three Parameters</H1>
<FORM method="POST" ACTION="ThreeParams.do">
First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
Second Parameter: <INPUT TYPE="TEXT" NAME="param2"><BR>
Third Parameter: <INPUT TYPE="TEXT" NAME="param3"><BR>
<CENTER><INPUT TYPE="SUBMIT"></CENTER>
</FORM>
</BODY>
</HTML>
----------------------------------------------------------------------
web.xml:
*********
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name>sevlets</servlet-name>
<servlet-class>ThreeParams</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlets</servlet-name>
<url-pattern>/ThreeParams.do</url-pattern>
</servlet-mapping>
</web-app>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


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

Joined: Sep 13, 2008
Posts: 1
Hi,

There is a spelling mistake in Servlet name of Web.xml file. Change it....

Also make sure that the .class file is getting into appropriate folder under Classes folder.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

"Java Thirsty", please check your private messages for an important administrative matter.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12791
    
    5
Your use of the directory "servlets" and the following:



placement of a class in the default package rather than a defined package suggest you are following out-dated advice and trying to rely on the "invoker" servlet.

Go read this FAQ entry right now.

Use of the invoker is a REALLY BAD IDEA!



Bill
aleem khan
Ranch Hand

Joined: Aug 07, 2008
Posts: 94
Since you are not able to access .html itself the tomacat has not started properly. After starting tomcat please verify that you are able to acces the default tomacat website/webpage. Then again once you are able to access the html file it prompts to enter some data (as per your code). After you enter the details and click submit button again it will throw error unless you correct the spelling of "servlet" as some one has already pointed out. Incorrect spelling "servlet" is noway related to the .html file.


SCJP(1.4), SCWCD, Oracle 9i SQL certified, Oracle PLSQL Developer Certified Associate
 
GeeCON Prague 2014
 
subject: The requested resource () is not available