jsp生成静态页面
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
String file_name=request.getParameter("file_name");//你要访问的jsp文件,如index.jsp
//则你访问这个servlet时加参数.?img align=absmiddle src=/images/emot/url.gif>http://localhost/toHtml?file_name=index
url = "/"+file_name+".jsp";//这是你要生成HTML的jsp文件,如
RequestDispatcher rd = sc.getRequestDispatcher(url);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final ServletOutputStream stream = new ServletOutputStream()
public void write(byte[] data, int offset, int length)
public void write(int b) throws IOException
final PrintWriter pw = new PrintWriter(new OutputStreamWriter(os));
HttpServletResponse rep = new HttpServletResponseWrapper(response)
public ServletOutputStream getOutputStream()
FileOutputStream fos = new FileOutputStream(name); //把jsp输出的内容写到xxx.htm
out.print("<p align=center><font size=3 color=red>亲亲宝宝首页已经成功生成</font></p>");
欢迎转载,请注明出处:亲亲宝宝