Java examples for Servlet JSP:Servlet
servlet response Writer
import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; public class Main{ public static void responseWriter( HttpServletResponse httpServletResponse, String responseMsg) { PrintWriter printWriter = null; httpServletResponse.setContentType("text/html"); httpServletResponse.setCharacterEncoding("UTF-8"); try {/*w w w . ja v a 2 s. c o m*/ printWriter = httpServletResponse.getWriter(); printWriter.println(responseMsg); printWriter.close(); } catch (IOException e) { e.printStackTrace(); } } }