示例#1
0
  public void _jspService(
      final javax.servlet.http.HttpServletRequest request,
      final javax.servlet.http.HttpServletResponse response)
      throws java.io.IOException, javax.servlet.ServletException {

    final java.lang.String _jspx_method = request.getMethod();
    if (!"GET".equals(_jspx_method)
        && !"POST".equals(_jspx_method)
        && !"HEAD".equals(_jspx_method)
        && !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
      response.sendError(
          HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSPs only permit GET POST or HEAD");
      return;
    }

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<html>\n");
      out.write("\t<head>\n");
      out.write("\t\t\n");
      out.write("\t\t\n");
      out.write("\t\t<link rel=\"stylesheet\" href=\"bootstrap/dist/css/bootstrap.css\">\n");
      out.write("\t</head>\n");
      out.write("\t<body>\n");
      out.write("\t\t<div id=\"wrapper\">\n");
      out.write("\t\t\t<nav class=\"navbar navbar-default\">\n");
      out.write("\t\t\t  <div class=\"container-fluid\">\n");
      out.write("\t\t\t    <!-- Brand and toggle get grouped for better mobile display -->\n");
      out.write("\t\t\t    <div class=\"navbar-header\">\n");
      out.write(
          "\t\t\t    \t<a href=\"servlet/Deco\" type=\"submit\" value=\"Deconnexion\"> Se déconnecter </a>\n");
      out.write("    \t\t\t</div>\n");
      out.write("    \t\t</div>\n");
      out.write("\n");
      out.write("\t\t\t<h1> Bonjour ");
      out.print(session.getAttribute("login"));
      out.write(" ! </h1></div>\n");
      out.write("\t\t\t\n");
      out.write("\t\t\t\t<ul>\n");
      out.write("\t\t\t\t");

      String shortPath = request.getContextPath() + "/users/" + session.getAttribute("login");
      String longPath =
          request.getServletContext().getRealPath("/") + "/users/" + session.getAttribute("login");
      String[] files = new File(longPath).list();

      for (String s : files) {
        out.write("\n");
        out.write("\t\t\t\t\t\t<li> <a download=\"");
        out.print(s);
        out.write("\" href=\"");
        out.print(shortPath);
        out.write('/');
        out.print(s);
        out.write('"');
        out.write('>');
        out.write(' ');
        out.print(s);
        out.write(" </a> </li>\n");
        out.write("\t\t\t\t");
      }
      out.write("\n");
      out.write("\t\t\t\t</ul>\n");
      out.write("\n");
      out.write("\t\t\t<div class=\"col-md-4 col-md-offset-4\">\n");
      out.write(
          "\t\t\t\t<form method=\"POST\" action=\"servlet/Upload\" enctype=\"multipart/form-data\"  >\n");
      out.write(
          "\t\t            <div class=\"form-group\"><label>File Input <input type=\"file\" name=\"file\" id=\"file\" /></div>\n");
      out.write(
          "\t\t            <input type=\"submit\" value=\"Upload\" name=\"upload\" class=\"btn btn-primary btn-lg btn-block\">\n");
      out.write("\t\t        </form>\n");
      out.write("\t   \t\t</div>\n");
      out.write("\t\t</div>\n");
      out.write("\t</body>\n");
      out.write("</head>\n");
      out.write("\n");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            if (response.isCommitted()) {
              out.flush();
            } else {
              out.clearBuffer();
            }
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  public void _jspService(
      final javax.servlet.http.HttpServletRequest request,
      final javax.servlet.http.HttpServletResponse response)
      throws java.io.IOException, javax.servlet.ServletException {

    final java.lang.String _jspx_method = request.getMethod();
    if (!"GET".equals(_jspx_method)
        && !"POST".equals(_jspx_method)
        && !"HEAD".equals(_jspx_method)
        && !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
      response.sendError(
          HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSPs only permit GET POST or HEAD");
      return;
    }

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=EUC-KR");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

      // String savePath = "C:\\Program Files\\Wowza Media Systems\\Wowza Streaming Engine
      // 4.2.0\\content\\safeme";
      String savePath =
          "C:\\Program Files (x86)\\Wowza Media Systems\\Wowza Streaming Engine 4.3.0\\content\\safeme";
      int sizelimit = 50 * 1024 * 1024;
      try {
        out.print("<br>");
        out.print("SavePath : " + savePath);
        MultipartRequest multi =
            new MultipartRequest(request, savePath, sizelimit, new DefaultFileRenamePolicy());

        // MultipartRequest를 다양하게 활용하기 위한 방법(확장..)
        /* Enumeration formNames = multi.getFileNames(); //폼의 이름 변경
        String formName = (String)formNames.nextElement(); //자료가 많을 경우엔 while문을 사용
        String fileName = multi.getFilesystemName(formName); //파일의 이름 얻기 */

        // multi.getFile("images");
      } catch (Exception e) {
        out.print("<br>");
        out.print("<br>");
        out.print("예외 상황 발생..!");
        out.print("<br>예외상황 : ");
        out.print(e);
      } finally {
        out.print("<br>");
        out.print("저장완료!");
      }

      out.write("\r\n");
      out.write("<p></p>");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            if (response.isCommitted()) {
              out.flush();
            } else {
              out.clearBuffer();
            }
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }