• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head first servlet problem

 
Rohit rocks
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys...

I have the following structure under webapps...
Ch1-->WEB-INF-->classes
in WEB-INF I have following web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<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_3_0.xsd"
version="3.0"
metadata-complete="true">
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/Servl</url-pattern>
</servlet-mapping>
</web-app>

and in classes i have the class file of java program Ch1Servlet.java

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 Chapter1 Servlet </h1>"
+ "<br>" + today + "</body>" +
"</html>" );

}
}

I have glassfish running on 8080..so I have configured tomcat to 7070...all examples are running correctly....but
when I give the URL "http://localhost:7070/ch1/Servl" it shows the error

HTTP Status 404 - /ch1/Servl

type Status report

message /ch1/Servl

description The requested resource is not available.
Apache Tomcat/7.0.47

I know this has already been asked...but still I failed to fix this......PLease help!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a list in the ServletsFaq that addresses this very issue. Check it out, it's sure to help.
 
Kumar Khiani
Ranch Hand
Posts: 40
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rohit,

Put ch1servlet in a package and try again
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's one of the items in the checklist.
 
Rohit rocks
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys for the reply..
Actually the problem was in Tomcat version I was using....I switched to Tomcat 5...and it worked...

Thanks again...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!