Professional Documents
Culture Documents
WAD Lab Manual
WAD Lab Manual
Step 5: Now delete your default "index.jsp" file and create a new "index.html" file and
write the following code for it.
index.html
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body bgcolor="pink">
<form method="get" action="Admin">
<table>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<input type="text" name="name"/><br/>
</td>
</tr>
<tr>
<td>
<b>Password:</b>
</td>
<td>
<input type="password" name="password"/><br/>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="Login">
</td>
</tr>
</table>
</form>
</body>
</html>
Step 6: Create a new servlet file named "Filter.java" and write the following code for it.
Filter.java
import java.io. IOException;
import java.io.PrintWriter;
import javax.servlet.*;
@Override
public void init(FilterConfig arg0) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
@Override
public void destroy() {
}
}
Step 7: Now create another servlet named "Admin.java" and write the following code for
it.
Admin.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("Welcome ADMIN");
out.close();
}
Password :murali123
Step 10:
Now enter a username and password depending on your choice. If you enter the
password as "admin" then you are permited to visit the site else a warning is shown each
time when you enter an incorrect password.
2.Authentication using JSP
}