把你的代码和web.xml文件 给我看看
我在jbuilder下试了一下 是可以的
testServlet.java 代码如下 :
package dzsb.web.user;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
/**
* <p>Title: dzsb</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: sun</p>
* @author michael.sun
* @version 1.0
*/
public class testServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html;
charset=GBK";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Get request
public voiddo
Get(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>testServlet</title></head>");
out.println("<body bgcolor=/"#ffffff/">");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("</body></html>");
}
//Process the HTTP Post request
public voiddo
Post(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>testServlet</title></head>");
out.println("<body bgcolor=/"#ffffff/">");
out.println("<p>The servlet has received a POST. This is the reply.</p>");
out.println("</body></html>");
}
//Clean up resources
public void destroy() {
}
}
web.xml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<!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>testservlet</servlet-name>
<servlet-class>dzsb.web.user.testServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testservlet</servlet-name>
<url-pattern>/testservlet</url-pattern>
</servlet-mapping>
</web-app>