|
|
@@ -111,67 +111,5 @@ public class ToHtmlServlet extends HttpServlet {
|
|
|
return file;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /*public void service(HttpServletRequest request, HttpServletResponse response)
|
|
|
- throws ServletException, IOException {
|
|
|
-
|
|
|
- String url = "";
|
|
|
- String name = "";
|
|
|
- ServletContext sc = getServletContext();
|
|
|
-
|
|
|
- String file_name = request.getParameter("file_name");
|
|
|
- url = "/design/my-survey-design!previewDev.action?surveyId=402880ea4675ac62014675ac7b3a0000";
|
|
|
-
|
|
|
- // 这是生成的html文件名,如index.htm.
|
|
|
- name = "/survey.htm";
|
|
|
- name = getServletContext().getRealPath(name);
|
|
|
-
|
|
|
- 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,
|
|
|
- "utf-8"));
|
|
|
-
|
|
|
- HttpServletResponse rep = new HttpServletResponseWrapper(response) {
|
|
|
- public ServletOutputStream getOutputStream() {
|
|
|
- return stream;
|
|
|
- }
|
|
|
-
|
|
|
- public PrintWriter getWriter() {
|
|
|
- return pw;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- // rd.include(request, rep);
|
|
|
- rd.forward(request, response);
|
|
|
- pw.flush();
|
|
|
-
|
|
|
- // 把jsp输出的内容写到xxx.htm
|
|
|
- File file = new File(name);
|
|
|
- if (!file.exists()) {
|
|
|
- file.createNewFile();
|
|
|
- }
|
|
|
- System.out.println(name);
|
|
|
- FileOutputStream fos = new FileOutputStream(file);
|
|
|
-
|
|
|
- os.writeTo(fos);
|
|
|
- fos.close();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- response.setContentType("text/html;charset=utf-8");
|
|
|
- PrintWriter out = response.getWriter();
|
|
|
- out.print("<p align=center><font size=3 color=red>首页已经成功生成!Andrew</font></p>");
|
|
|
- }*/
|
|
|
|
|
|
}
|