Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

HTTP Status 404 - /ch1/Serv | The requested resource is not available.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am preparing for SCWCD .i am using tomcat version 7.
Error:
HTTP Status 404 - /ch1/Serv
type Status report

message /ch1/Serv

description The requested resource is not available.

Apache Tomcat/7.0.82


Code: Ch1Servlet .java

package com.example;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Ch1Servlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {

PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();

out.println("<html>"+"<body>"+"<h1 align=center>HF\'s Chap1 Servlet</h1>"+"
"
+today+"</body>"+"</html>");

}
}


Web.xml.
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" 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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
 <servlet-name>Chapter1 Servlet</servlet-name>
 <servlet-class>com.example.Ch1Servlet</servlet-class>
</servlet>

<servlet-mapping>
 <servlet-name>Chapter1 Servlet</servlet-name>
 <url-pattern>/Serv1</url-pattern>
</servlet-mapping>

</web-app>

Command executed:
javac -classpath /D:\sanjay\software\apache-tomcat-7.0.82-windows-x64\apache-tomcat-7.0.82\lib/servlet-api.jar -d classes src\com\example\Ch1Servlet.java

put the class file and web xml file into below folder str.

class file copid: D:\sanjay\software\apache-tomcat-7.0.82-windows-x64\apache-tomcat-7.0.82\webapps\ch1\web-inf\classes\com\example
Web xml copied: D:\sanjay\software\apache-tomcat-7.0.82-windows-x64\apache-tomcat-7.0.82\webapps\ch1\web-inf

Started the server and type the URL: http://localhost:8080/ch1/Serv in browser.

I am getting above error. I am struggling with this such a long time. Can any one please help.

 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Url is made up of three parts
#1 - The Tomcat Server - http://localhost:8080
#2 - Your web application context - defaults to the folder you created under webapps - ch1
#3 - The resource within your web application you want to call - the url-pattern you have used in the web.xml:  Serv1

You were trying:  http://localhost:8080/ch1/Serv
Try adding the '1' on the end of that to match exactly what you have in your web.xml file
 
Sanjay Kumar Singh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stefan,

I tried that as well.

http://localhost:8080/ch1/Serv1

but getting same result.
 
Sanjay Kumar Singh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, It worked.
I had created web-inf folder in small.

after changing this folder to caps. it worked.

Thank you
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic