Reputation: 2049
This is a simple html page:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>GET_POST</title>
</head>
<body>
<h5> Insert username and password </h5>
<form action ="./get_Post" method ="post">
username: <br>
<input type = "text" name = "username">
<br>
password:<br>
<input type = "password" name ="password">
<br><br>
<input type = "submit" value = "LOGIN">
</form>
</body>
</html>
The form of this html page called the servlet has /get_Post as url-mapping in web.xml.
Now, this is doPost method of the servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String password = request.getParameter("password");
PrintWriter out = response.getWriter();
out.println(password);
}
I expected null pointer exception, and instead the servlet gets the password I put in the html form. What can I do to make private password information?
Upvotes: 1
Views: 448
Reputation: 1386
If you're worried about security you need to enable SSL. For tomcat; first create a keystore and then add an SSL connector description to server.xml
<Connector port="8443" scheme="https" secure="true" SSLEnabled="true"
keystoreFile="somekeystore" sslProtocol="TLS"
keystorePass="pwd" />
Then forward login requests to HTTPS page and redirect to HTTP after authorization.
Upvotes: 2