I’m open to
eclipse –> new –> dynamic web
project –> in target runtime –> new
Apache Tomcat v6.0 and establish mark
Create a new local server –> next
Browse establish way
C:\dev\apache-tomcat-6.0.29-windows-x86\apache-tomcat-6.0.29
–> finish –> in new dynamic project finish
in Java Resources : src new class
java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class f extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
resp.setContentType("text/html;charset=utf-8");
PrintWriter pw = resp.getWriter();
pw.println("<H1>Hello, world! или Привет мир</H1>");
}
}
–>server start in save resources s.java been modified. Save changes? I’m yes. –> Run servlet/s –> result
HTTP Status 404 – /s/servlet/s
type Status report
message /s/servlet/s
description The requested resource (/s/servlet/s) is not available.
Apache Tomcat/6.0.14
How and when I’m error?
How need the create right?
I’m sorry, bad English. explain most clear and distinctly
Have you checked the
web.xmldeployment descriptor?There you have to define your servlet mapping, or otherwise the servlet container won’t have notice of the servlet.
Example:
And now, you can access it with your mapped path (“
/<contextPath>/myServlet“) or with the default invoker (“/<contextPath>/servlet/s“).