diff --git a/webui/src/main/java/com/muwire/webui/ConfigurationServlet.java b/webui/src/main/java/com/muwire/webui/ConfigurationServlet.java index 649c4c1a..d466364f 100644 --- a/webui/src/main/java/com/muwire/webui/ConfigurationServlet.java +++ b/webui/src/main/java/com/muwire/webui/ConfigurationServlet.java @@ -1,10 +1,13 @@ package com.muwire.webui; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.io.PrintStream; import java.util.Enumeration; import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -15,20 +18,26 @@ import com.muwire.core.Core; public class ConfigurationServlet extends HttpServlet { private Core core; + private ServletContext context; @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - - clearAllBooleans(); - - Enumeration patameterNames = req.getParameterNames(); - while(patameterNames.hasMoreElements()) { - String name = patameterNames.nextElement(); - String value = req.getParameter(name); - update(name, value); + try { + clearAllBooleans(); + + Enumeration patameterNames = req.getParameterNames(); + while(patameterNames.hasMoreElements()) { + String name = patameterNames.nextElement(); + String value = req.getParameter(name); + update(name, value); + } + core.saveMuSettings(); + core.saveI2PSettings(); + context.setAttribute("MWConfigError", null); + } catch (Exception e) { + context.setAttribute("MWConfigError", e); } - core.saveMuSettings(); - core.saveI2PSettings(); + resp.sendRedirect("/MuWire/ConfigurationPage"); } @@ -70,6 +79,7 @@ public class ConfigurationServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { + context = config.getServletContext(); core = (Core) config.getServletContext().getAttribute("core"); } diff --git a/webui/src/main/webapp/ConfigurationPage.jsp b/webui/src/main/webapp/ConfigurationPage.jsp index b132bdbb..de3d2a68 100644 --- a/webui/src/main/webapp/ConfigurationPage.jsp +++ b/webui/src/main/webapp/ConfigurationPage.jsp @@ -18,6 +18,8 @@ String inboundLength = core.getI2pOptions().getProperty("inbound.length"); String inboundQuantity = core.getI2pOptions().getProperty("inbound.quantity"); String outboundLength = core.getI2pOptions().getProperty("outbound.length"); String outboundQuantity = core.getI2pOptions().getProperty("outbound.quantity"); + +Exception error = (Exception) application.getAttribute("MWConfigError"); %> @@ -31,6 +33,10 @@ String outboundQuantity = core.getI2pOptions().getProperty("outbound.quantity"); <%@include file="sidebar.jsi"%>
+<% if (error != null) { %> +
<%=error%>
+<% } %> +

<%=Util._t("Search")%>