0% found this document useful (0 votes)
9 views17 pages

Exp 12-15 WT

The document outlines a series of programming tasks and experiments focused on web development using HTML, JavaScript, JSP, and Servlets. It includes creating web pages, validating user input, and managing a student database with functionalities for inserting, updating, and deleting records. Additionally, it covers connecting to a database and displaying employee information through a servlet application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views17 pages

Exp 12-15 WT

The document outlines a series of programming tasks and experiments focused on web development using HTML, JavaScript, JSP, and Servlets. It includes creating web pages, validating user input, and managing a student database with functionalities for inserting, updating, and deleting records. Additionally, it covers connecting to a database and displaying employee information through a servlet application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

INDEX

S.N Date of Date of Sign


Name of the Program Implementation Submission

1 Create a simple webpage using HTML.


2 Create a HTML page which has properly aligned
paragraph with Image along with it.
3 Write a program to display list of items in different
styles.
4 Use frames to include Images and Videos.
5 Add a Cascading Style Sheet to design a Webpage.
6 Design a dynamic web page with validation using
JavaScript
7 Write a program using JavaScript to demonstrate the
concept of built-in array methods.
8 Write a program using JavaScript to demonstrate the
concept of nested functions.
9 Write programs using JavaScript for Web Page to
display browsers information.
10 Write a program using JavaScript to merge property
of two objects.
11 Write a program using JavaScript to include a JS file
into another JS file.
12 Develop a Servlet to validate user name and
password stored in database. Display authorized
user is she/he is authorized else display
unauthorized user.
13 Write JSP & Servlet program to store student
details sent from registration form in to
database table.
14 Write appropriate JSP pages to insert, update and
delete data in student table in a single application
with proper linking of JSP pages and session
management.
15 Write a java program/servlet application to
connect to a database and extract data from the
table containing employee’s information and
display them.
16 Write program to demonstrate the concept of spring
and spring boot.
17 Create REST Service for an Education Site.
18 Use the Spring Boot Starter Web to Create a Web
Application.
EXPERIMENT – 12
12. Develop a Servlet to validate user name and password stored in the database. Display
authorized user is she/he is authorized else display unauthorized user.
SQL File

LoginServlet.java
web.xml

login.html
OUTPUT:-

For Authorized User:


EXPERIMENT – 13
13. Write JSP & Servlet program to store student details sent from registration form into
database table.
Student Database
RegisterServlet.java
Web.xml
EXPERIMENT – 14
14. Write appropriate JSP pages to insert, update and delete data in student table in a single
application with proper linking of JSP pages and session management.
Student table

insert.jsp
<% if (session.getAttribute("user") == null) {
response.sendRedirect("login.jsp"); return;
}
%>

<h2>Insert Student</h2>
<form method="post">
Name: <input type="text" name="name"/><br><br>
Email: <input type="text" name="email"/><br><br>
Course: <input type="text" name="course"/><br><br>
<input type="submit" value="Insert"/>
</form>

<%@ include file="db.jsp" %>

<%
String name = request.getParameter("name");
String email = request.getParameter("email");
String course = request.getParameter("course");

if (name != null && email != null && course != null) {


PreparedStatement ps = conn.prepareStatement("INSERT INTO students(name, email, course) VALUES (?, ?,
?)"); ps.setString(1, name); ps.setString(2, email);
ps.setString(3, course); int i =
ps.executeUpdate(); if (i > 0) {
out.println("<p>Student Inserted Successfully!</p>");
}
conn.close();
}
%>

<a href="view.jsp">Back to Dashboard</a>

update.jsp
<% if (session.getAttribute("user") == null) {
response.sendRedirect("login.jsp"); return;
}
%>

<h2>Update Student</h2>
<form method="post">
ID to Update: <input type="text" name="id"/><br><br>
New Name: <input type="text" name="name"/><br><br>
New Email: <input type="text" name="email"/><br><br>
New Course: <input type="text" name="course"/><br><br>
<input type="submit" value="Update"/>
</form>

<%@ include file="db.jsp" %>

<%
String id = request.getParameter("id");
String name = request.getParameter("name");
String email = request.getParameter("email");
String course = request.getParameter("course");

if (id != null && name != null && email != null && course != null) {
PreparedStatement ps = conn.prepareStatement("UPDATE students SET name=?, email=?, course=? WHERE
id=?"); ps.setString(1, name); ps.setString(2, email); ps.setString(3, course);
ps.setInt(4, Integer.parseInt(id)); int i =
ps.executeUpdate(); if (i > 0) {
out.println("<p>Student Updated Successfully!</p>"); } else {
out.println("<p>ID not found!</p>");
}
conn.close();
}
%>

<a href="view.jsp">Back to Dashboard</a>

delete.jsp
<% if (session.getAttribute("user") == null) {
response.sendRedirect("login.jsp"); return;
}
%>

<h2>Delete Student</h2>
<form method="post">
ID to Delete: <input type="text" name="id"/><br><br>
<input type="submit" value="Delete"/>
</form>

<%@ include file="db.jsp" %>

<%
String id = request.getParameter("id");

if (id != null) {
PreparedStatement ps = conn.prepareStatement("DELETE FROM students WHERE id=?");
ps.setInt(1, Integer.parseInt(id)); int i =
ps.executeUpdate(); if (i > 0) {
out.println("<p>Student Deleted Successfully!</p>");
} else {
out.println("<p>ID not found!</p>");
}
conn.close();
}
%>

<a href="view.jsp">Back to Dashboard</a>

view.jsp
<% if (session.getAttribute("user") == null) {
response.sendRedirect("login.jsp"); return;
}
%>

<h2>Welcome, <%= session.getAttribute("user") %>!</h2>

<a href="insert.jsp">Insert Student</a> |


<a href="update.jsp">Update Student</a> |
<a href="delete.jsp">Delete Student</a> |
<a href="logout.jsp">Logout</a>
<br><br>

<%@ include file="db.jsp" %>

<h3>All Students</h3>
<table border="1">
<tr><th>ID</th><th>Name</th><th>Email</th><th>Course</th></tr> <%
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM students"); while (rs.next()) {
%>
<tr>
<td><%= rs.getInt("id") %></td>
<td><%= rs.getString("name") %></td>
<td><%= rs.getString("email") %></td>
<td><%= rs.getString("course") %></td>
</tr>
<%
}
conn.close();
%>
</table>

db.jsp
<%@ page import="java.sql.*" %>
<%
Connection conn = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/studentdb", "root", " ");
} catch (Exception e) { out.println(e);
}
%>
OUTPUT:-
EXPERIMENT – 15
Write a Java program/servlet application to connect to a database and extract data from the
table containing employee’s information and display them.

EmployeeServlet.java File
WEB.XML File

MYSQL File

OUTPUT :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy