~ started fixing error messages
Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
102a8ebdb9
commit
4068239070
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
%>
|
||||
|
||||
<div class="row">
|
||||
<div class="col s4 push-s4">
|
||||
<div class="card-panel red darken-1">
|
||||
<h5 class="white-text center-align">
|
||||
<%= errorCode.getMessage()%>
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
<%@include file="theming.jsp"%>
|
|
@ -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();
|
||||
|
|
|
@ -144,6 +144,16 @@
|
|||
<div class="modal-footer">
|
||||
|
||||
</div>
|
||||
|
||||
<div id="error" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Es ist ein Fehler aufgetreten</h4>
|
||||
<p id="error-message">A bunch of text</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Ok</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue