Win a copy of Rust Web Development this week in the Other Languages forum!

Sanjay Kumar Singh

Greenhorn
+ Follow
since Dec 16, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sanjay Kumar Singh

Thanks, It worked.
I had created web-inf folder in small.

after changing this folder to caps. it worked.

Thank you
4 years ago
Thanks Stefan,

I tried that as well.

http://localhost:8080/ch1/Serv1

but getting same result.
4 years ago
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.

4 years ago