相思资源网 Design By www.200059.com
复制代码 代码如下:
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
public class toHtml extends HttpServlet
{
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String url="";
String name="";
ServletContext sc = getServletContext();
String file_name=request.getParameter("file_name");//你要访问的jsp文件,如index.jsp
//则你访问这个servlet时加参数.如http://localhost/toHtml?file_name=index
url = "/"+file_name+".jsp";//这是你要生成HTML的jsp文件,如
//http://localhost/index.jsp的执行结果.
name="/home/resin/resin-2.1.6/doc/"+file_name+".htm";//这是生成的html文件名,如index.htm.
RequestDispatcher rd = sc.getRequestDispatcher(url);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final ServletOutputStream stream = new ServletOutputStream()
{
public void write(byte[] data, int offset, int length)
{
os.write(data, offset, length);
}
public void write(int b) throws IOException
{
os.write(b);
}
};
final PrintWriter pw = new PrintWriter(new OutputStreamWriter(os));
HttpServletResponse rep = new HttpServletResponseWrapper(response)
{
public ServletOutputStream getOutputStream()
{
return stream;
}
public PrintWriter getWriter()
{
return pw;
}
};
rd.include(request, rep);
pw.flush();
FileOutputStream fos = new FileOutputStream(name); //把jsp输出的内容写到xxx.htm
os.writeTo(fos);
fos.close();
PrintWriter out=response.getWriter();
out.print("<p align=center><font size=3 color=red>首页已经成功生成!Andrew</font></p>");
}
}
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
public class toHtml extends HttpServlet
{
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String url="";
String name="";
ServletContext sc = getServletContext();
String file_name=request.getParameter("file_name");//你要访问的jsp文件,如index.jsp
//则你访问这个servlet时加参数.如http://localhost/toHtml?file_name=index
url = "/"+file_name+".jsp";//这是你要生成HTML的jsp文件,如
//http://localhost/index.jsp的执行结果.
name="/home/resin/resin-2.1.6/doc/"+file_name+".htm";//这是生成的html文件名,如index.htm.
RequestDispatcher rd = sc.getRequestDispatcher(url);
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final ServletOutputStream stream = new ServletOutputStream()
{
public void write(byte[] data, int offset, int length)
{
os.write(data, offset, length);
}
public void write(int b) throws IOException
{
os.write(b);
}
};
final PrintWriter pw = new PrintWriter(new OutputStreamWriter(os));
HttpServletResponse rep = new HttpServletResponseWrapper(response)
{
public ServletOutputStream getOutputStream()
{
return stream;
}
public PrintWriter getWriter()
{
return pw;
}
};
rd.include(request, rep);
pw.flush();
FileOutputStream fos = new FileOutputStream(name); //把jsp输出的内容写到xxx.htm
os.writeTo(fos);
fos.close();
PrintWriter out=response.getWriter();
out.print("<p align=center><font size=3 color=red>首页已经成功生成!Andrew</font></p>");
}
}
标签:
jsp生成静态页面的方法
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无jsp生成静态页面的方法的评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。