This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
pw.println("<html>"); pw.println("<head>"); pw.println("</head>"); pw.println("<body>"); pw.println("<h3> Hello World - From Ramesh </h3> "); pw.println("</body>"); pw.println("<html>"); }
} and put web.xml under webapps\chapter01\WEB-INF <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>HelloWorldServlet</servlet-name> <servlet-class>HelloWorldServlet</servlet-class> </servlet> </web-app>
But here what I have doubt....it says type the following on browser http://localhost:8080/chapter01/servlet/HelloWorldServlet where did this servlet directory comes from .... I even tried to remove the servlet directory it still says Apache Tomcat/4.0.1 - HTTP Status 404 - /chapter/servlet/HelloWorldServlet description The requested resource (/chapter/servlet/HelloWorldServlet) is not available.
Hello Ramesh, Your example works in a servlet container with an 'invoker servlet' enabled. Older versions of Tomcat used to enable it by default. For an explanation of the 'invoker servlet' read this: http://test.javaranch.com/wiki/view?InvokerServlet To make your example work, add this to your web.xml file:
Add it after the servlet element, after the closing </servlet>. For an explanation on why this works now, check section 5.2.3 in 'SCWCD Exam Study Kit' by Hanumant Deshmukh. Nart [ March 18, 2004: Message edited by: Nart Seine ] [ March 18, 2004: Message edited by: Nart Seine ]
Joined: Apr 08, 2003
Hi Nart, Thanks for your quick response...Still I have one double from where does this "/servlet/ " comes from....You can see from the code that I didn't put it in any package.... <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/servlet/HelloWorldServlet</url-pattern></servlet-mapping>
I tried still not working ...I know I am missing very small thing... Thanks for you time Ramesh
Joined: May 28, 2002
This is how web.xml should look like:
Your deploymeny directory structure would like this:
Hi Nart, My sincere thanks for you reply. It was a great help to have that jar file.. I made a lot of mistakes like...classpath, home directory...etc... I had too many Tomcat installed...each one pointing each direction....finally I made it to run... Thanks Ramesh