java - tomcat7 404 error when deploying -
I am trying to reproduce the solution given in this question, but I still get the same error Has been there.
This is the servlet code:
edu @ubuntu: ~ / ch1 $ cat ch1servlet.java package com.example; Import javax.servlet. *; Import javax.servlet.http.http. *; Import java.io * *; Public class C1 serletlet HTTPServlet {Public Zero Dotgate (HTTP Serial Request Request, HTTPServelet Response Feedback) throws IOException {printWriter Out = Response .getWriter (); Java.util.Date today = new java.util.Date (); out.println ("& lt; html> from" + "to & lt; body & gt;" + "& lt; h1 align = center & gt; hf's Chapter1 servlet & lt; / h1 & gt;" + "" + "& Lt; br>" + today + "& lt; / body & gt;" + "& lt; / html & gt;"); }} with which was compiled:
edu @ubuntu: ~ / ch1 / web-enf $ javac -classpath / usr / share / tomcat7 / lib / servlet-api.jar -d classes ../ch1servlet.java edu @ Ubuntu: ~ / ch1 / web-nf $ ls classes / com / example / c1 eswallet.class classes / com / example / c1 This is the content of web.xml edu @ Ubuntu: ~ / ch1 / WEB-INF $ cat web.xml & lt; eswl.txt ? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Web-app xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" XSI: Schema location = "http : //java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "version =" 3.0 "& gt; & Lt; Servlet & gt; & Lt; Servlet-name & gt; Chapter 1 Servlet & lt; / Servlet-name & gt; & Lt; Servlet category & gt; Com.example.ch1servlet & lt; / Servlet category & gt; & Lt; / Servlet & gt; & Lt; Servlet-mapping & gt; & Lt; Servlet-name & gt; Chapter 1 Servlet & lt; / Servlet-name & gt; & Lt; URL pattern & gt; / Serv1 & lt; / URL pattern & gt; & Lt; / Servlet-mapping & gt; & Lt; / Web application & gt;
Then I copied the ch1 directory to $ CATALINA_HOME / webapps
edu @ Ubuntu: ~ / ch1 $ cd .. edu @ Ubuntu: ~ $ ps -oa | Grep tomcat tomcat7 1053 0.3 11.3 2557684 85272? Sol 03:12 0:51 / usr / lib / jvm / java-8-oracle / bin / java -dajava.util.logging.config.file = / var / lib / tomcat7 / conf / logging.properties -Djava.util .logging.manager = org.apache.juli.ClassLoaderLogManager -Djava.awt.headless = True-Xmx128m -XX: + UseConcMarkSweepGC -Djava.endorsed.dirs = / usr / share / tomcat7 / support -classpath / usr / share / tomca 7 / bin / bootstrap.jar: /usr/share/tomcat7/bin/tomcat-juli.jar-Dcatalina.base = / var / lib / tomcat7 -Dcatalina.home = / usr / share / tomcat7 -Djava.io.tmpdir = / tmp / tomcat7-tomcat7-tmp org.apache.catalina.startup.bootstrap start edu 2259 0.0 0.1 11,744 916 points / 1s + 07:24 00:00 Grape --color = Auto badge edu @ ubuntu: ~ $ sudo mkdir / usr / share / tomcat7 / webapps edu @ ubuntu: ~ $ sudo cp -rf ch1 / usr / share / tomcat7 / webapps / edu @ ubuntu: ~ $ ls / usr / share / tomcat7 / webapps / ch1 edu @ ubuntu : ~ $ when I try to reach 192.168.1.45:8080/ch1/Serv1
Get me the notorious 404 "requested resource (/ ch1 / Serv1 /) is not available"
This Using the version of Java:
edu @ Ubuntu: ~ $ Java-version Java version "1.8.0_05" Java (TM) SE Runtime Environment (1.8.0_05-B13 Built-in) Java Hotspot (TM) 64-bit server VM (25.5-B02, composite mode creation) I have a dozen times different tutorials A repeated the process and I always got stuck in the same point.
After copying your file and modifying web.xml, you get the new web. To load the xml file, you must restart the tomcat.
Comments
Post a Comment