diff options
| -rw-r--r-- | WebContent/WEB-INF/web.xml | 24 | ||||
| -rw-r--r-- | src/de/fhswf/in/inf/fit/aufgabe3/LoginServlet.java | 13 |
2 files changed, 29 insertions, 8 deletions
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000..1fd1e4e --- /dev/null +++ b/WebContent/WEB-INF/web.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> + <display-name>FIT</display-name> + <welcome-file-list> + <welcome-file>index.html</welcome-file> + <welcome-file>index.htm</welcome-file> + <welcome-file>index.jsp</welcome-file> + <welcome-file>default.html</welcome-file> + <welcome-file>default.htm</welcome-file> + <welcome-file>default.jsp</welcome-file> + </welcome-file-list> + <context-param> + <param-name>username</param-name> + <param-value>admin</param-value> + </context-param> + <context-param> + <param-name>password</param-name> + <param-value>12345</param-value> + </context-param> + <context-param> + <param-name>salt</param-name> + <param-value>aabbcc112233</param-value> + </context-param> +</web-app>
\ No newline at end of file diff --git a/src/de/fhswf/in/inf/fit/aufgabe3/LoginServlet.java b/src/de/fhswf/in/inf/fit/aufgabe3/LoginServlet.java index c33949f..7f56c3e 100644 --- a/src/de/fhswf/in/inf/fit/aufgabe3/LoginServlet.java +++ b/src/de/fhswf/in/inf/fit/aufgabe3/LoginServlet.java @@ -6,7 +6,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.servlet.ServletException; -import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -15,10 +14,7 @@ import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class LoginServlet */ -@WebServlet(urlPatterns = { "/LoginServlet" }, initParams = { - @WebInitParam(name = "username", value = "admin"), - @WebInitParam(name = "password", value = "12345"), - @WebInitParam(name = "salt", value = "aabbcc112233") }) +@WebServlet("/LoginServlet") public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; @@ -48,9 +44,10 @@ public class LoginServlet extends HttpServlet protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String validUsername = getInitParameter("username").toLowerCase(); - String validPassword = getInitParameter("password"); - String salt = getInitParameter("salt"); + String validUsername = getServletContext().getInitParameter("username") + .toLowerCase(); + String validPassword = getServletContext().getInitParameter("password"); + String salt = getServletContext().getInitParameter("salt"); String requestUsername = request.getParameter("username").toLowerCase(); String requestPassword = request.getParameter("password"); |
