outp

My Cart

Create a login page using JSP and JDBC. Database is to be created in O

Question


Create a login page using JSP and JDBC. Database is to be created in Oracle


Posted on : 2022-09-16 15:45:34 | Author : IGNOU Academy | View : 35

Click Here to Order on WhatsApp

Login or SignUp to View Answer / Comment or Ask Question.. Its Free

Word Count : 1362

simple login page using JSP and JDBC with an Oracle database:

php
Copy code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
  <form action="login" method="post">
    <table>
      <tr>
        <td>Username:</td>
        <td><input type="text" name="username"></td>
      </tr>
      <tr>
        <td>Password:</td>
        <td><input type="password" name="password"></td>
      </tr>
      <tr>
        <td><input type="submit" value="Login"></td>
        <td><input type="reset" value="Reset"></td>
      </tr>
    </table>
  </form>
</body>
</html>
The JSP code above creates a simple HTML form with two text fields, one for the username and one for the password, and two buttons for submitting the form and resetting the fields. The form's action attribute is set to "login" and its method is set to "post".

Next, you would need to create a servlet to handle the login form submissions and perform the authentication against the Oracle database. Here is an example of how the servlet could look like:

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/login")
public class LoginServlet extends HttpServlet {

  private static final long serialVersionUID = 1L;

  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

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

    Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;

    try {
      Class.forName("oracle.jdbc.driver.OracleDriver");
      connection = DriverManager.getConnection("jdbc:oracle:thin:@<hostname>:<port>:<sid>", "user", "password");
      statement = connection.createStatement();
      resultSet = statement.executeQuery("SELECT * FROM users WHERE username='" + username + "' AND password='" + password + "'");
      if (resultSet.next()) {
        response.sendRedirect("welcome.jsp");
      } else {
        response.sendRedirect("error.jsp");
      }
    } catch (ClassNotFoundException | SQLException e) {
      e.printStackTrace();
    } finally {
      try {
        if (resultSet != null) {
          resultSet.close();
        }
        ________ ____________ _________ ___________ ________ _______ ______ ____ _________ ______ _________ ____________ ________ ____________.
____ ____________ __________ ____ ____________ ___________ _______ ____ ____ ________ _______ ____________.
____ _____________ ________ ____________ _______ ___________ ____________ _________ ____ ________ _________ __________.
____ _____________ ______ _______ _________ _______ _________ _______ ____________ ______ ____________ ________.
__ ______ ______ _____________ _______ ___________ _________ ________ _________ ___ ____.
___ _____________ __ _____________ __ _____ _________ _______ _________.
________ ____ ______ _____ _________ ____________.
_________ ___________ ____________ __ _______ ________ ________ _________ _______ _______ __ ____________.
________ ___ __ _____________ ____________ __ _______ ________ _______ ______.
___ ___ ____ ___________ _____ _____________ ____________ __ _____ ____________.
_________ _______ ___ __________ ______ ______ __________ ___________.
____________ _____ __________ __________ ______ __________ ____ ______ _____________ _________.
__ _____ ____ ___ _________ ____ ___.
_____ _____ _____________ ____ _____________ _____ ___ __ ____________.
_________ __ ____________ ____ _______ __.
___________ _________ __________ ___ ____ _______ ______ ___________ __ __________ ____________ ___________ ________.
_____________ _______ __________ _______ ________ ____.
_____________ _____________ ___ ______ __ _____ __________ _________ ____________ ___ _____________ _________ ___________ _______.
_____________ __________ ___________ __________ _________ __________ _________ ________ _________ ___ _________ ___________ ______ __________ _________.
____________ _____ ___ ____________ ____ __ ___ ___ ________ __ __ _____ ____________ ___ __________.
____ ______ _________ _______ ___ ____________ __ ____________ _____ ___ ________ ____________ __.
_______ ___ _____ _____ __________ _____ ____ _________ _________ _____________ ____________ _______.
____________ __ _____ ____ _________ ________ __________ ________ __ ___ ____________ _____________.
_________ _______ ___ ___________ _________ _______ _____ _________.
________ ____ ____________ __ _____ ___ ___________.
_______ ___________ _________ __________ _____ __ _________ ___________ ____________ ________ __________ ________ ___.
_____ __ ________ ____________ ___________ _____________ ______ ______ _____________ _____.
____ _____ ____________ _____ ___ _____________ ________ ____________ ______ ___ ___.
__ ____________ __ ____________ _______ ___________ ____ ______ _______.
__ _____________ _______ ___________ ____________ ____ ______ _____________ __________ __________.
________ ___ __ _____________ __________ _________ _________ ________ _____ _____________ ____________ _______ ______.
___ __________ ______ ________ ____ ____ ______ _____________ ___________ ______.
___ ______ _________ _________ ____ ___________ ____________ ___________ ___________ __ ______.
_________ _________ ___________ _____________ _____ _______ __________.
_____________ ____________ ________ ___________ ____ ___ ______ _____ _____________ _____ ______ ___________ __ _____.
___ ____ ___________ _______ ______ ______ ________ ________ ________ ____ _____________ _____________ _____ ________.
____ __________ ____ _______ _____________ _____________ ____.
_______ __ __________ ____________ ____________ __ ____ _______ _____________ ___ ___________ __________.
____________ __________ _____ _________ ______ ___________ ____ __________ ____ __ _______ _________.
_____ ____ _________ _____ ___________ _________.
_________ _________ ____ ____ __________ ______ ________ ______ ________.
____ ___ ________ _____________ _____ _____________ ________ _____________.
____ ________ __ _________ _____________ ___________ ____ _________ _____ __ _____ ________ ____________ __________ _________.
___ _____ _______ __________ ______ ___ __________ ________.
_______ _______ _________ ____ _______ __ __________ __________ _________ _______ ________ __.
________ ________ _____________ ____ ________ ______ _____________.
___________ ___ _____ ___________ ____________ _________ __ ______ ____________ ___________ ___ _________ _____________ _____________ _________.
_________ _______ ________ ___________ ____ ___________.
_________ _______ ____________ ________ ___________ ______ ________ _______ __ __________ ___________ ________ _______ _________.
____________ ____ ________ ____________ ________ _____________ ____ _______ _______ __ ____________ ________ ________.
____ __ ____________ _____ ____ _______ ___ ___________ _______.
_________ _________ _____ ___ _________ _____________ _________ _______ __ ___ ___________ _______ _____ _____ __________.
_________ _______ ________ __ _____ _____________ ___ _____________ ______ __ ___ _____ ___ ____________.
_______ _______ __ __________ ___________ __________ ______ ___________ _________ ___________ __ _______ ____ _______.
_________ _______ _________ ___________ _____________ ____________ ________ ____________ ______ ___ __________ __ ____ ____________.
___________ ________ _______ ________ ____ ______ _____________ ___________ __________ __________.
____ ___ _____ _________ __ __________ ____ _____ _____.
_____ _________ __________ __ ___________ _____________ _______ _____________ _____ ____________ ______ ___ _____________ ______.
______ __ __________ _________ ___________ ___________ _____ ___________ _____ _____________ _____________ _______ ____________.
________ ______ _________ _______ ____ _____ __________ ______ _____ _____ ___________ _____.
___________ ____________ __________ ___________ ____ _____.
_____ __ ______ ________ __________ _______ _________ ___.
___________ _______ __ ____________ ________ ___________ ______ _________ _____ __________ _____________ ________ _______ __________ ___________.
__ ______ __________ _________ ________ ___ __ _________ __________ __________ _____ _________.
___ __________ _________ ____________ ___ __________ _____ ______ _____ _______ _________ ________.
___ ____________ ________ _________ ______ ____ _________ _________ ____________ ______ ____________ ________.
___________ __ ___________ __ ___________ ___________ _________ ___________ __ ___ _________ __ ____ ____ __________.
___ _________ ___ ___________ __ _______ _____ _____ _________ ___ _______.
_____ ___ _________ __ _______ _____ __ _____________ ____ _____________ __________ _____ _______.
____ _______ __________ ____________ _____ _____________ _____ _______ ________ ________ ___________ ______ ____ _____ __________.
___________ _____________ ________ _____ ________ __.
______ ___ __________ ____________ _______ ___________ __ ____________.
_____ _____ ________ _____ ______ __________ __ _________ _______ ________.
____________ ___ _____ ___________ ___________ _____ _____ ____ _______ ____________ ________ ___ ______ __.
_______ _____ __ __ _____________ ___.
____________ ________ ___________ _______ ____________ __________ ______ ______ ___________ _________ ______ _________ ______ _________.
________ _______ ________ _____ ___ ____ __________.
_________ ___________ ________ ____________ _________ ______ _______ _________ ___________ ___ ______ ______ __ _______.
___ _________ ______ _____________ _______ __ ___________ ____.
___________ _________ ___ ___________ _________ ______ _________.
________ ___ ____ ___ _____________ ___ __________ __ ________ _______ ___________ _______.
____ _____ _________ _____ _________ _____________ __________ ____ ________.
_______ ________ ________ _____ _____ ___ _________ ___________ ________.
___ ___ _________ ______ ______ _______ ________ _______ _________ _____________ _____________ _____.
Click Here to Order Full Assignment on WhatsApp








Degree : MASTER DEGREE PROGRAMMES
Course Name : Master of Computer Applications
Course Code : MCA
Subject Name : Advanced Internet Technologies
Subject Code : MCS 51
Year : 2022 2023



IGNOU MCS 51 Solved Assignment 2022 2023
Click Here to Order on WhatsApp

Call Now
Contact Us
Welcome to IGNOU Academy

Click to Contact Us

Call - 9199852182 Call - 9852900088 myabhasolutions@gmail.com WhatsApp - 9852900088
New to IGNOU Login to Get Every Update