I finally got my classpath and everything set up for j2ee. Now I'm running into a problem whenever I try to run tomcat, and then try to run the servlet. It says "The requested resource is not available".
I typed this in as the URL: http://localhost:8080/ch1/Serv1
Here is the java code:
XML Code..Although I have no clue what it's for, and what I wrote:Code:import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Ch1Servlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) { try { PrintWriter out = response.getWriter(); java.util.Date today = new java.util.Date(); out.println("<html>" + "<body>" + "<h1 align=center>Chapter 1 Servlet></h1>" + today.toString() + "</body>" + "</html>"); } catch(IOException ioe) { ioe.printStackTrace(); } } }
Code:<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>Chapter1 Servlet</servlet-name> <servlet-class>Ch1Servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Chapther1 Servlet</servlet-name> <url-pattern>/Serv1</url-pattern> </servlet-mapping> </web-app>
Please help me out!




Reply With Quote