package servlet; import core.process.C_StudentUploadOpeningReport; import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @WebServlet("/home/student-upload-opening-report") @MultipartConfig public class S_StudentUploadOpeningReport extends HttpServlet { static String fileType = "graduation_design_opening_report"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id = request.getParameter("id"); String fileURL = null; try { fileURL = servlet.Utils.saveFile(request, fileType); }catch (Exception e) { System.out.print(e); response.sendRedirect("/op_fail.jsp"); } C_StudentUploadOpeningReport p =new C_StudentUploadOpeningReport(); p.setOpeningReportURL(fileURL); p.setGraduationDesignId(id); try { p.uploadOpeningReport(); } catch (Exception e) { e.printStackTrace(); response.sendRedirect("/op_fail.jsp"); } } }