package com;

import 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 ajaxServlet extends HttpServlet 

{
  
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException 
  {
      response.setContentType(
"text/xml");
      PrintWriter out 
= response.getWriter();
      
//String action = request.getParameter("action");
      out.println("<html>");
      out.println(
"<head><title>测试</title></head>");
      out.println(
"<body>");
      out.println(
"<h1>Hellow Servlet!汉字????</h1>");
      out.println(
"</body>");
      out.println(
"</html>");
  }    
}

<?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>
 
<description>Empty web.xml file for Web Application</description>
 
<servlet>
  
<servlet-name>testservlet</servlet-name>
  
<servlet-class>com.ajaxServlet</servlet-class>
 
</servlet>
    
<servlet-mapping>
        
<servlet-name>testservlet</servlet-name>
        
<url-pattern>/testservlet</url-pattern> 
    
</servlet-mapping>
</web-app>