0% found this document useful (0 votes)
25 views4 pages

JSPJDBC

nice
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)
25 views4 pages

JSPJDBC

nice
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/ 4

1. <!

DOCTYPE html>
2. <html>
3. <head>
4. <meta charset="ISO-8859-1">
5. <title>Insert title here</title>
6. </head>
7. <body>
8.
9. Sample login Example (try with username as "admin" and password as
"admin" without quart ) <br> <br>
10.
11. <form action="LoginController" method="post">
12.
13. Enter username :<input type="text" name="username"> <br>
14. Enter password :<input type="password" name="password"><br>
15. <input type="submit" value="Login">
16.
17.
18. </form>
19.
20. </body>
21. </html>

<?xml version="1.0" encoding="UTF-8"?>


<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>login</display-name>
<servlet>
<description></description>
<display-name>LoginController</display-name>
<servlet-name>LoginController</servlet-name>
<servlet-class>com.candidjava.LoginController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginController</servlet-name>
<url-pattern>/LoginController</url-pattern>
</servlet-mapping>

</web-app>

1. package com.candidjava;
2.
3. import java.io.IOException;
4. import javax.servlet.ServletException;
5. import javax.servlet.http.HttpServlet;
6. import javax.servlet.http.HttpServletRequest;
7. import javax.servlet.http.HttpServletResponse;
8.
9. /**
10. * Servlet implementation class LoginController
11. */
12. public class LoginController extends HttpServlet {
13.
14. protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
15. String un=request.getParameter("username");
16. String pw=request.getParameter("password");
17.
18. if(un.equals("admin") && pw.equals("admin"))
19. {
20. response.sendRedirect("success.html");
21. return;
22. }
23. else
24. {
25. response.sendRedirect("error.html");
26. return;
27. }
28. }
29.
30. }

success page

1. <!DOCTYPE html>
2. <html>
3. <head>
4. <meta charset="ISO-8859-1">
5. <title>Insert title here</title>
6. </head>
7. <body>
8.
9.
10. Login success
11.
12. </body>
13. </html>
14. <!DOCTYPE html>
15. <html>
16. <head>
17. <meta charset="ISO-8859-1">
18. <title>Insert title here</title>
19. </head>
20. <body>
21. Invalid username or password
22. </body>
23. </html>

You might also like