1 package com.zhiyuan.servlet;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5 import javax.servlet.ServletException;
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9
/**
* <p>Title: 响应SERVLET
* <p>Company:
* @description RespServlet
* @author LIANG ZHIYUAN
* @date 2016年5月4日下午9:41:00
* @version 1.0
*/
public class RespServlet extends HttpServlet {
/**
* 串行号
*/
private static final long serialVersionUID = 4176783017819187776L;
/**
* Constructor of the object.
*/
public RespServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
String content=request.getParameter("data");
String str = new String(content.getBytes("ISO-8859-1"),"utf-8");
PrintWriter writer=response.getWriter();
writer.print(str);
System.out.println(str);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
}
}