Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
21 views3 pages

8.web Application Using Servelet and JDBC: Package

This document describes a web application that uses a servlet and JDBC for login authentication. The servlet checks submitted username and password parameters against hardcoded credentials, and redirects to either a success or error page accordingly. The application includes an HTML form to collect credentials, the LoginController servlet class, and success and error response pages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

8.web Application Using Servelet and JDBC: Package

This document describes a web application that uses a servlet and JDBC for login authentication. The servlet checks submitted username and password parameters against hardcoded credentials, and redirects to either a success or error page accordingly. The application includes an HTML form to collect credentials, the LoginController servlet class, and success and error response pages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

8.

WEB APPLICATION USING SERVELET AND JDBC

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

Sample login Example (try with username as "admin" and password as "admin" without quart
)<br><br>

<form action="LoginController" method="post">

Enter username :<input type="text" name="username"><br>

Enter password :<input type="password" name="password"><br>

<input type="submit" value="Login">

</form>

</body>

</html>

PACKAGE:

packagecom.candidjava;

importjava.io.IOException;

importjavax.servlet.ServletException;

importjavax.servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest;

importjavax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class LoginController

*/

public class LoginController extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {

String un=request.getParameter("username");

String pw=request.getParameter("password");

if(un.equals("admin") &&pw.equals("admin"))

response.sendRedirect("success.html");

return;

else

response.sendRedirect("error.html");

return;

}
<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

Login success

</body>

</html>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Insert title here</title>

</head>

<body>

Invalid username or password

</body>

</html>

You might also like