KEMBAR78
WT LAB Work | PDF | World Wide Web | Internet & Web
0% found this document useful (0 votes)
48 views22 pages

WT LAB Work

lab document.

Uploaded by

Shikha Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views22 pages

WT LAB Work

lab document.

Uploaded by

Shikha Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

Department of Computer Science and Engineering

Web Technology Lab


(KCS-652)

Name: Shikha Singh

Roll No: 2107510100049

Year: 3rd

Submitted By: Shikha Singh Submitted To: Mr. Prashant Tripathi


Index
Sr.No. Name of the Experiment Date Remark
1 Write HTML/Java scripts to display your CV in
navigator, your Institute website, Department
Website and Tutorial website for specific subject.

2 Write an HTML program to design an entry form of


student details and send it to store at database server
MySQL.

3 Write programs using Java script for Web Page to


display browsers information.

4 Write a Java applet to display the Application


Program screen i.e. calculator and other.

5 Writing program in XML for creation of DTD,


which specifies set of rules. Create a style sheet in
CSS/ XSL & display the document in internet
explorer.

6 Program to illustrate JDBC connectivity. Program


for maintaining database by sending queries.
Design and implement a simple servlet book query
with the help of JDBC & SQL. Create MS Access
Database, Create on ODBC link, Compile &
execute JAVA JDVC Socket.

7 Install TOMCAT web server and APACHE. Access


the above developed static web pages for books
web site, using these servers by putting the web
pages developed.

8 Assume four users user1, user2, user3 and user4


having the passwords pwd1, pwd2, pwd3 and pwd4
respectively. Write a servlet for doing the
following. Create a Cookie and add these four user
id's and passwords to this Cookie. 2. Read the user
id and passwords entered in the Login form and
authenticate with the values available in the
cookies.

9 Install a database (Mysql or Oracle). Create a table


which should contain at least the following fields:
name, password, email-id, phone number Write a
java program/servlet/JSP to connect to that database
and extract data from the tables and display them.
Insert the details of the users who register with the
web site, whenever a new user clicks the submit
button in the registration page.

10 Write a JSP which insert the details of the 3 or 4


users who register with the web site by using
registration form. Authenticate the user when he
submits the login form using the user name and
password from the database.

Experiment No: 1
OBJECTIVE: Write HTML/Java scripts to display your CV in navigator, your Institute website,
Department Website and Tutorial website for specific subject.

PROGRAM:

1. Navigator (Browser) Display: To display your CV in a web browser (navigator), you can
create an HTML file (cv.html) with the following content:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your CV</title>
</head>
<body>
<h1>Your CV</h1>
<p>Education, experience, skills, etc.</p>
<!-- Add more sections as needed -->
</body>
</html>

2. Institute Website: If you want to display your CV on your institute’s website, you’ll need to
upload the cv.html file to the appropriate directory on the server where your institute’s website
is hosted. The URL to access your CV would be something like
https://www.example.com/cv.html.

3. Department Website: Similarly, for the department website, upload the cv.html file to the
relevant directory on the department’s server. The URL would be specific to your department,
such as https://www.example.com/department/cv.html.

4. Tutorial Website for a Specific Subject: If you want to create a tutorial website related to a
specific subject (e.g., Java programming), you can create a separate HTML file for that tutorial.
For example, let’s say you want to create a tutorial on “Introduction to Java.” You can create
an intro_to_java.html file with relevant content and upload it to the tutorial website.

OUTCOME: Student will understand how to develop static webpages in HTML.

Experiment No: 2
OBJECTIVE: Write HTML/Java scripts to display your CV in navigator, your Institute website,
Department Website and Tutorial website for specific subject.

PROGRAM:

Create a student details entry form using JavaServer Pages (JSP). JSP allows you to embed Java code
directly into your HTML pages.

Create the JSP Form: Below is an example of a JSP form for collecting student details. Save this
as student_form.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" %>


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Student Details Form</title>
</head>
<body>
<h1>Student Details Form</h1>
<form action="insert.jsp" method="POST">
<label for="fname">First Name:</label>
<input type="text" id="fname" name="fname" required><br>

<label for="lname">Last Name:</label>


<input type="text" id="lname" name="lname" required><br>

<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br>

<!-- Add more fields as needed -->

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


</form>
</body>
</html>

Create the JSP Script (insert.jsp): Create a JSP script (insert.jsp) that will handle the form
submission and insert the data into the MySQL database. Here’s a basic example:

<%@ page language="java" contentType="text/html; charset=UTF-8" %>


<%@ page import="java.sql.*" %>
<%
String fname = request.getParameter("fname");
String lname = request.getParameter("lname");
String email = request.getParameter("email");

try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/your_database", "your_username",
"your_password");
String sql = "INSERT INTO students (first_name, last_name, email) VALUES (?, ?, ?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, fname);
pstmt.setString(2, lname);
pstmt.setString(3, email);
pstmt.executeUpdate();
out.println("Record inserted successfully!");
conn.close();
} catch (Exception e) {
out.println("Error: " + e.getMessage());
}
%>

Replace the placeholders (your_username, your_password, your_database, and students) with your
actual MySQL credentials and table name.

Database Setup: Ensure that you have a MySQL server running. Create a database and a table
(e.g., students) with appropriate columns (e.g., first_name, last_name, email).

Testing: Place both the JSP form (student_form.jsp) and the JSP script (insert.jsp) in the same folder
under your server’s webapps directory (e.g., Tomcat’s webapps folder). Access the form via your
browser (e.g., http://localhost:8080/your_app/student_form.jsp). Submit data, and it should be inserted
into the database.

Experiment No: 3

OBJECTIVE: Write programs using Java script for Web Page to display browsers information.
PROGRAM:

Browser Name and Version: The following code snippet retrieves and displays the browser name and
version and also the operating system (platform):

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Browser Information</title>
</head>
<body>
<h1>Browser Information</h1>
<p id="browser-info"></p>
<p id="os-info"></p>

<script>
const browserInfo = `Browser: ${navigator.appName} (Version ${navigator.appVersion})`;
document.getElementById("browser-info").textContent = browserInfo;
const osInfo = `Operating System: ${navigator.platform}`;
document.getElementById("os-info").textContent = osInfo;

</script>
</body>
</html>

This code snippet uses the navigator.appName and navigator.appVersion properties to get the browser
name and version. The navigator.platform property provides information about the user’s operating
system.

Other Browser Properties: We can diaplay additional properties from the navigator object to get more
details. For example:

 navigator.language: Displays the browser’s language.


 navigator.userAgent: Shows the user-agent header sent by the browser.

 navigator.cookieEnabled: Indicates whether cookies are enabled.

Experiment No: 4

OBJECTIVE: Write a Java applet to display the Application Program screen i.e. calculator and other.
PROGRAM:

The applet allows you to perform addition, subtraction, multiplication, and division. The following
steps should be followed for simple Java applet that creates a basic calculator:

1. Create a text field to accept the expression and display the output.
2. Create buttons for digits (0-9) and a decimal point.
3. Add a button to clear the complete expression.
4. Create buttons for operations (addition, subtraction, multiplication, and division) and an equals
button to compute the result.
5. Add ActionListeners to all the buttons.
6. Compute the result and display it in the text field.

Here’s the source code for the basic calculator applet:


import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Calculator extends Applet implements ActionListener {


TextField inp;

public void init() {


setBackground(Color.white);
setLayout(null);

inp = new TextField();


inp.setBounds(150, 100, 270, 50);
this.add(inp);

Button[] button = new Button[10];


for (int i = 0; i < 10; i++) {
button[i] = new Button(String.valueOf(9 - i));
button[i].setBounds(150 + ((i % 3) * 50), 150 + ((i / 3) * 50), 50, 50);
this.add(button[i]);
button[i].addActionListener(this);
}

Button dec = new Button(".");


dec.setBounds(200, 300, 50, 50);
this.add(dec);
dec.addActionListener(this);

Button clr = new Button("C");


clr.setBounds(250, 300, 50, 50);
this.add(clr);
clr.addActionListener(this);

String[] operators = { "/", "*", "-", "+", "=" };


for (int i = 0; i < 4; i++) {
Button operator = new Button(operators[i]);
operator.setBounds(300, 150 + (i * 50), 50, 50);
this.add(operator);
operator.addActionListener(this);
}
}

public void actionPerformed(ActionEvent e) {


// Handle button clicks and perform calculations
// You can implement the logic here based on the button clicked
// For example, when the "+" button is clicked, add the numbers and display the result
}
}

Experiment No: 5
OBJECTIVE: Writing program in XML for creation of DTD, which specifies set of rules. Create a
style sheet in CSS/ XSL & display the document in web browser.

PROGRAM:

XML File: Save your XML document with a .xml extension. For example, you could name
it document.xml.

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


<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Abc</to>
<from>Xyz</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

DTD File: Save your DTD (Document Type Definition) with a .dtd extension. This file should be in
the same directory as your XML file. For example, you could name it note.dtd.

<!ELEMENT note (to,from,heading,body)>


<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>

CSS File: Save your CSS (Cascading Style Sheets) with a .css extension. For example, you could
name it styles.css.

note {
font-family: Arial, sans-serif;
margin: 4px;
padding: 5px;
background-color: #f8f8f8;
border: 1px solid #ddd;
}

Displaying in a Browser: To display the XML document with the CSS styles in a browser, you
need to transform the XML document into an XHTML document using XSLT (XSL
Transformations). Unfortunately, CSS cannot be applied directly to XML documents in most
modern web browsers.

To perform step 4, you need to use XSLT (XSL Transformations) to transform your XML
document into an XHTML document. Here’s how you can do it:

XSLT File: First, you need to create an XSLT file. Save it with a .xsl extension. For example, you
could name it transform.xsl. This file will define how to transform the XML document into
XHTML.

XML
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My Note</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">To</th>
<th style="text-align:left">From</th>
</tr>
<tr>
<td><xsl:value-of select="note/to"/></td>
<td><xsl:value-of select="note/from"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Linking the XSLT File: Next, you need to link the XSLT file in your XML document. You can do
this by adding the following line to your XML file:

XML

<?xml-stylesheet type="text/xsl" href="transform.xsl"?>

Your XML file should now look like this:

XML

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


<?xml-stylesheet type="text/xsl" href="transform.xsl"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

Opening in a Browser: Now, you can open your XML file in a web browser. The browser will
apply the XSLT transformation and display the resulting XHTML document.

Experiment No: 6
OBJECTIVE: Program to illustrate JDBC connectivity. Program for maintaining database by sending
queries. Design and implement a simple servlet book query with the help of JDBC & SQL. Create MS
Access Database, Create on ODBC link, Compile & execute JAVA JDVC Socket.

PROGRAM:

JDBC Connectivity:

JDBC (Java Database Connectivity) allows Java applications to interact with databases. Here’s a
basic example of how to establish a JDBC connection to a MySQL database:

import java.sql.*;
public class FirstExample {
static final String DB_URL = "jdbc:mysql://localhost/kipm";
static final String USER = "guest";
static final String PASS = "guest123";
static final String QUERY = "SELECT id, first, last, age FROM Employees";
public static void main(String[] args) {
try (Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(QUERY)) {
while (rs.next()) {
System.out.print("ID: " + rs.getInt("id"));
System.out.print(", Age: " + rs.getInt("age"));
System.out.print(", First: " + rs.getString("first"));
System.out.println(", Last: " + rs.getString("last"));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}

This code connects to a MySQL database, executes a query, and displays the results.

Creating a MySQL Database:


To create a MySQL database, you can use the following SQL command:

CREATE DATABASE your_database_name;


(Replace your_database_name with the desired name for your database2.)

1. Creating an ODBC Link:


o To create an ODBC link, follow these steps:

 Search for or browse to the “ODBC Data Sources” applet (64-bit or 32-bit) in
the Start Menu or Control Panel.

 On the Drivers tab, you’ll find a list of installed ODBC drivers.

 Choose the appropriate driver and configure the connection settings3.


2. Compiling and Executing a Java JDBC Socket:
o It seems there might be a typo in your request (“JDVC” instead of “JDBC”).
Assuming you meant JDBC, here’s how you can compile and execute a Java program
that uses JDBC:

 Write your Java code that establishes a JDBC connection (as shown in the
first example).

 Compile your Java file using javac FirstExample.java.

 Run your compiled program using java FirstExample.


Experiment No: 7

OBJECTIVE: Install TOMCAT web server and APACHE. Access the above developed static web
pages for books web site, using these servers by putting the web pages developed.

PROGRAM:

1. Install Apache Tomcat:


o Apache Tomcat is a popular web server and servlet container for Java-based web
applications. Follow these steps to install it:

1. Download Tomcat:

 Visit the official Apache Tomcat download page.

 Choose the appropriate version (usually the latest stable version) and
download the ZIP or TAR.GZ file.

2. Extract the Archive:

 Extract the downloaded archive to a directory of your choice.

3. Set Environment Variables (Optional):

 Set the CATALINA_HOME environment variable to point to the Tomcat


installation directory.

4. Start Tomcat:

 Navigate to the bin directory within the Tomcat installation.

 Run the startup script (startup.sh for Unix/Linux or startup.bat for


Windows).

 Tomcat will start and listen on port 8080 by default.

5. Access Tomcat:

 Open a web browser and visit http://localhost:8080.

 You should see the Tomcat welcome page.

2. Install Apache HTTP Server (Apache):

o Apache HTTP Server is a powerful and widely used web server. Follow these steps to
install it:
1. Download Apache:

 Visit the official Apache HTTP Server download page.

 Choose the appropriate version (usually the latest stable version) and
download the ZIP or TAR.GZ file.

2. Extract the Archive:

 Extract the downloaded archive to a directory of your choice.

3. Start Apache:

 Navigate to the bin directory within the Apache installation.

 Run the startup script (httpd or httpd.exe).

 Apache will start and listen on port 80 by default.

4. Access Apache:

 Open a web browser and visit http://localhost.

 You should see the default Apache welcome page.

3. Deploy Your Static Web Pages:

o Place your static web pages (HTML, CSS, JavaScript, images, etc.) in the appropriate
directories:

 For Apache Tomcat: Put your web pages in the webapps directory within the
Tomcat installation. Create a subdirectory (e.g., mybooks) and place your files
there.

 For Apache HTTP Server: Put your web pages in the htdocs or www directory
within the Apache installation.

o Access your web pages using the following URLs:

 For Tomcat: http://localhost:8080/mybooks/your_page.html

 For Apache: http://localhost/your_page.html


Experiment No: 8

OBJECTIVE: Assume four users user1, user2, user3 and user4 having the passwords pwd1, pwd2,
pwd3 and pwd4 respectively. Write a servlet for doing the following. Create a Cookie and add these
four user id's and passwords to this Cookie. 2. Read the user id and passwords entered in the Login
form and authenticate with the values available in the cookies.

PROGRAM:

We’ll create a cookie containing the user IDs and passwords, and then authenticate users based on the
values stored in the cookies. Below is a example of how you can achieve this using Java servlets:

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
// Assume user IDs and passwords
String[] userIDs = {"user1", "user2", "user3", "user4"};
String[] passwords = {"pwd1", "pwd2", "pwd3", "pwd4"};

// Create a cookie to store user IDs and passwords


Cookie userCookie = new Cookie("UserCredentials",
"user1:pwd1,user2:pwd2,user3:pwd3,user4:pwd4");
response.addCookie(userCookie);

// Read user input from the login form


String enteredUserID = request.getParameter("userId");
String enteredPassword = request.getParameter("password");

// Authenticate user based on cookie values


boolean isAuthenticated = false;
String[] userCredentials = userCookie.getValue().split(",");
for (String credential : userCredentials) {
String[] parts = credential.split(":");
String storedUserID = parts[0];
String storedPassword = parts[1];
if (enteredUserID.equals(storedUserID) && enteredPassword.equals(storedPassword)) {
isAuthenticated = true;
break;
}
}

// Display appropriate message


if (isAuthenticated) {
response.getWriter().println("Welcome, " + enteredUserID + "!");
} else {
response.getWriter().println("You are not an authenticated user.");
}
}
}

Here’s what the servlet does:


 Creates a cookie named “UserCredentials” containing the user IDs and passwords.
 Reads the user input (entered user ID and password) from the login form.
 Authenticates the user by comparing the input with the values stored in the cookie.
 Displays a welcome message if the user is authenticated; otherwise, displays an error message.

Adjust the servlet path (@WebServlet("/LoginServlet")) and the HTML form in your JSP or HTML
file accordingly. Also, handle exceptions and edge cases as needed in a production environment.
Experiment No: 9

OBJECTIVE: Install a database Mysql. Create a table which should contain at least the following
fields: name, password, email-id, phone number Write a java program/servlet/JSP to connect to that
database and extract data from the tables and display them. Insert the details of the users who register
with the web site, whenever a new user clicks the submit button in the registration page.

PROGRAM:

Install MySQL from its official website:

Creating the Database Table:


We’ll create a table named users with the required fields: name, password, email, and phone_number.
Here’s an example of how you can create the table using SQL:

CREATE TABLE users (


id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
phone_number VARCHAR(15) NOT NULL
);

In this table:
id is an auto-incremented primary key.
name, password, email, and phone_number are columns to store user information.

Java Servlet to Connect and Extract Data:


You can create a Java servlet to connect to the MySQL database and retrieve user data.

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

@WebServlet("/UserServlet")
public class UserServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
try {
// Load MySQL JDBC driver
Class.forName("com.mysql.cj.jdbc.Driver");

// Establish database connection


String url = "jdbc:mysql://localhost:3306/your_database_name";
String username = "your_username";
String password = "your_password";
Connection connection = DriverManager.getConnection(url, username, password);

// Retrieve user data


String query = "SELECT name, email, phone_number FROM users";
PreparedStatement preparedStatement = connection.prepareStatement(query);
ResultSet resultSet = preparedStatement.executeQuery();

// Display user data (you can format this as needed)


while (resultSet.next()) {
String name = resultSet.getString("name");
String email = resultSet.getString("email");
String phone = resultSet.getString("phone_number");
// Display or process the retrieved data
// (e.g., send it to JSP for rendering)
}

// Close resources
resultSet.close();
preparedStatement.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

Inserting User Details:


When a new user registers on your website, you can insert their details into the users table.
You’ll need another servlet or JSP page to handle the registration form submission.
In that servlet, extract the user’s input (name, password, email, phone number) and insert it into the
database using an INSERT INTO query.

Experiment No: 10

OBJECTIVE: Write a JSP which insert the details of the 3 or 4 users who register with the web site by
using registration form. Authenticate the user when he submits the login form using the user name and
password from the database.

PROGRAM:

Part 1: Creating the Registration Form (Registration.jsp)

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Registration Form</title>
<style>
/* CSS styles for the registration form container */
.registration-container {
width: 600px;
margin: 0 auto;
padding: 20px;
border: 2px solid #ccc;
border-radius: 10px;
background-color: #f9f9f9;
}
/* CSS styles for input fields */
.input-field {
width: 100%;
padding: 8px;
margin: 5px 0;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="registration-container">
<h2>Registration Form</h2>
<form action="RegistrationHandler" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" class="input-field" required><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" class="input-field" required><br>
<!-- Add other fields (e.g., name, email, etc.) as needed -->
<input type="submit" value="Register">
</form>
</div>
</body>
</html>

Part 2: Implementing User Authentication (RegistrationHandler.java)

1. Create a Java servlet named RegistrationHandler (you can adjust the name as needed).
2. In the servlet, handle the form submission by extracting the user input (username and password)
and inserting it into the MySQL database.

3. You’ll need to set up a MySQL database with a table (e.g., users) to store user information.

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

@WebServlet("/RegistrationHandler")
public class RegistrationHandler extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");

// Database connection details


String dbURL = "jdbc:mysql://localhost:3306/your_database_name";
String dbUser = "your_db_username";
String dbPassword = "your_db_password";

try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection connection = DriverManager.getConnection(dbURL, dbUser, dbPassword);

// Insert user data into the 'users' table


String insertQuery = "INSERT INTO users (username, password) VALUES (?, ?)";
PreparedStatement preparedStatement = connection.prepareStatement(insertQuery);
preparedStatement.setString(1, username);
preparedStatement.setString(2, password);
preparedStatement.executeUpdate();

// Redirect to a success page or login page


response.sendRedirect("login.jsp"); // Change to your login page
preparedStatement.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
// Handle any exceptions (e.g., duplicate username, database errors)
// Redirect to an error page if needed
response.sendRedirect("error.jsp"); // Change to your error page
}
}
}

You might also like