Hello, there is an example from the book Head first Servlets and JSP, which cannot be started.
web.xml (Path: webapps \ ch1 \ WEB-INF)
<?xml version=”1.0” encoding=”ISO-8859-1”?> <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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd” version=”2.4”> <servlet> <servlet-name>Chapter1Servlet</servlet-name> <servlet-class>Ch1Servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Chapter1Servlet</servlet-name> <url-pattern>/Serv1</url-pattern> </servlet-mapping> </web-app> Ch1Servlet.class (Path: webapps \ ch1 \ WEB-INF \ classes)
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>"); } } Browser URL: http: // localhost: 8080 / ch1 / Serv1
No connection to the site Host localhost rejected the connection request. ERR_CONNECTION_REFUSED
Tomcat runs fine, standard examples too. What is the trouble?