diff --git a/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java b/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java index 3f09c45..dacf593 100644 --- a/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java +++ b/src/main/java/de/hsel/spm/baudas/web/UploadServlet.java @@ -60,6 +60,7 @@ public class UploadServlet extends HttpServlet { protected void doPost(@NotNull HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding(StandardCharsets.UTF_8.name()); + Part filePart = req.getPart("file"); if (filePart == null) { @@ -113,7 +114,7 @@ public class UploadServlet extends HttpServlet { */ private void error(@NotNull HttpServletResponse response, @NotNull ErrorCode code) { try { - response.sendRedirect("error.jsp?code=" + code); + response.getWriter().write(code.getMessage()); } catch (IOException e) { BauDas.getLogger().throwing(this.getClass().getName(), this.getClass().getEnclosingMethod().getName(), e); } diff --git a/src/main/webapp/error.jsp b/src/main/webapp/error.jsp deleted file mode 100644 index a137dce..0000000 --- a/src/main/webapp/error.jsp +++ /dev/null @@ -1,32 +0,0 @@ -<%@ page import="de.hsel.spm.baudas.web.ErrorCode" %> -<%@ page import="java.nio.charset.StandardCharsets" %> -<%@ page import="java.util.List" %> -<%@ page import="java.util.Arrays" %> -<%@ page import="java.util.ArrayList" %> -<%@ page contentType="text/html;charset=UTF-8" %> -<%@include file="emptyHeader.jsp"%> -<% response.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> -<% request.setCharacterEncoding(StandardCharsets.UTF_8.name()); %> - -<% - String code = request.getParameter("code"); - - if(code != null && ErrorCode.exists(code)){ - ErrorCode errorCode = ErrorCode.valueOf(code); -%> - -
-
-
-
- <%= errorCode.getMessage()%> -
-
-
-
-<% - } -%> - - -<%@include file="theming.jsp"%> \ No newline at end of file diff --git a/src/main/webapp/js/upload.js b/src/main/webapp/js/upload.js index 03c1f39..5c187d0 100644 --- a/src/main/webapp/js/upload.js +++ b/src/main/webapp/js/upload.js @@ -7,6 +7,7 @@ */ let form = document.getElementById("upload"); +let error = $('#error'); form.onsubmit = function (event) { event.preventDefault(); @@ -22,6 +23,17 @@ form.onsubmit = function (event) { loading.modal('open'); }; + xhr.onreadystatechange = function() { + if (xhr.readyState == XMLHttpRequest.DONE) { + if(xhr.responseText != null) { + loading.modal('close'); + console.log(xhr.responseText); + $('#error-message').text(xhr.responseText); + error.modal('open'); + } + } + } + xhr.onloadend = function (e) { clearSelected(); updateDatasets(); diff --git a/src/main/webapp/menu.jsp b/src/main/webapp/menu.jsp index d222eb7..9b7d49f 100644 --- a/src/main/webapp/menu.jsp +++ b/src/main/webapp/menu.jsp @@ -144,6 +144,16 @@ + +