SET AS HOME PAGE

ADD TO FAVORITES / BOOKMARK THIS WEBSITE (More Details)

Introduction

Servlet

Jsp

Security

Enterprise Beans

Contact Us


Securing Web Applications - Project

 Introduction

  1. To counter security threats, you can implement different security techniques, such as:
    • Authentication: Identifies a user.
    • Authorization: Specifies the rights assigned to an authenticated user to access resources of a Web application.
    • Data Integrity: Ensures that data is not modified while being transferred between the server and the client.
    • Auditing: Secures Web applications by maintaining a record of the rights assigned to different types of Web users.
CLICK HERE to download this complete example (zip file)


 Creating a Servlet for Form-Based Authentication (LoginSuccess.java)

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class LoginSuccess extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
Try
{
response.setContentType("text/html");
PrintWriter display = response.getWriter();
display.println("<html><body>");
display.println("Thank you, You have been successfully authenticated using form-based authentication.");
display.println("</body></html>");
display.close();
}
catch(Exception exc)
{
exc.printStackTrace();
}
}
}
Download: LoginSuccess.java

 Creating a Login Form (login.html)

Note: Here, use j_security_check, j_username, j_password. This predefined names and are used by the Application server
<form method="post" action="j_security_check">
<input type="text" name="j_username">
<input type="password" name="j_password">
<html>
<head>
<title>
Form-based Login Authentication
</title>
</head>
<body bgcolor="lightblue">
<br><br>
<center>
<h2>Please Login to Authenticate Yourself</h2>
<form method="post" action="j_security_check">
<table>
<tr>
<td>User Name: </td>
<td><input type="text" name="j_username"></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="j_password"></td>
</tr>
<tr>
<td><input type="submit" value="Login"></td>
<td><input type="reset" value="Reset"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
Download: login.html

 Creating an Error Page (error.html)

<html>
<head>
<title>
Error in Authentication
</title>
</head>
<body bgcolor="lightblue">
<br><br>
<h3><center>Sorry, your Authentication failed. </center></h3>
</body>
</html>
Download: error.html


 Click Next To Continue ...
<- PREVIOUSNEXT ->