Why can 't run Sevlet in Tomcat5 2003-09-19 - By Edward King
Back I have a servlet file,like follows:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class a1 extends HttpServlet{ public void doGet(HttpServletResponse req,HttpServletResponse resp) throws ServletException,IOException{ PrintWriter pw=resp.getWriter(); pw.println("<html><body>Hello World!</body></html>"); pw.close(); } }
and web.xml is follows: <?xml version="1.0" encoding="ISO-8859 (See http://ISO-8859.ora-code.com)-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>a1</servlet-name> <servlet-class>a1</servlet-class> </servlet> </web-app>
I use Tomcat5.0,I don't want to use Tomcat5 default path ,so I put a1.class into \Tomcat 5.0\webapps\test\WEB-INF\classes,and I have added a sentence into server.xml,like follows:
<Context path="test" docBase="test" debug="0"/>
but when I run it in IE6,like follows: http://localhost:8080/test/servlets/a1
it raises HTTP Status 404 error,"The requested resource (/test/servlets/a1) is not available."
Why? I have configure path! Please help. Thanks in advance Edward
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <META content="MSHTML 6.00.2800.1226" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT size=2><FONT size=3>I have a servlet file,like follows:</FONT></FONT></DIV> <DIV><FONT size=2><FONT size=3><BR>import javax.servlet.*;<BR>import javax.servlet.http.*;<BR>import java.io.*;<BR>public class a1 extends HttpServlet{<BR> public void doGet(HttpServletResponse req,HttpServletResponse resp) throws ServletException,IOException{<BR> PrintWriter pw=resp.getWriter();<BR> pw.println("<html><body>Hello World!</body></html>");<BR> pw.close();<BR> }<BR>}<BR><BR>and web.xml is follows:<BR><?xml version="1.0" encoding="ISO-8859 (See http://ISO-8859.ora-code.com)-1"?><BR><BR><!DOCTYPE web-app<BR> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"<BR> "</FONT><A href="http://java.sun.com/dtd/web-app_2_3.dtd"><FONT size=3>http://java.sun.com/dtd/web-app_2_3.dtd</FONT></A><FONT size=3>"><BR><BR><web-app><BR> <servlet><BR> <servlet-name>a1</servlet-name><BR> <servlet-class>a1</servlet-class><BR> </servlet><BR></web-app><BR><BR>I use Tomcat5.0,I don't want to use Tomcat5 default path ,so I put a1.class into \Tomcat 5.0\webapps\test\WEB-INF\classes,and I have added a sentence into server.xml,like follows:<BR><BR><Context path="test" docBase="test" debug="0"/><BR><BR>but when I run it in IE6,like follows:<BR></FONT><A href="http://localhost:8080/test/servlets/a1"><FONT size=3>http://localhost:8080/test/servlets/a1</FONT></A><BR><BR><FONT size=3>it raises HTTP Status 404 error,"The requested resource (/test/servlets/a1) is not available."<BR><BR>Why? I have configure path! Please help.<BR>Thanks in advance<BR>Edward</FONT><BR></DIV></FONT></BODY></HTML> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff SERVLET-INTEREST". <p> Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html <p>
|
|