KEMBAR78
WT Code | PDF | Foods
0% found this document useful (0 votes)
4 views54 pages

WT Code

The document contains HTML, CSS, and JavaScript code for various web applications, including a restaurant website with a menu, an employee management system in XML format, a calculator application, and a registration form. Each section includes the structure and styling necessary to create functional web pages. The code demonstrates the use of forms, tables, and basic interactivity through JavaScript.

Uploaded by

Yashodhan Gupta
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)
4 views54 pages

WT Code

The document contains HTML, CSS, and JavaScript code for various web applications, including a restaurant website with a menu, an employee management system in XML format, a calculator application, and a registration form. Each section includes the structure and styling necessary to create functional web pages. The code demonstrates the use of forms, tables, and basic interactivity through JavaScript.

Uploaded by

Yashodhan Gupta
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/ 54

PRACTICAL 2

Code:-
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Web Technology Assignment 2</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body style="background-image:url('images/bg.jpg');";>
<div class="container">
<div class="navbar">
<h1>Eat n Smile</h1>
<ul>
<li>Home</li>
<li><a href="menu.html">Menu</a></li>
<li>Contact</li>
</ul>
</div>

<div class="content">
<div class="welcome-section">
<h3>Welcome to,</h3>
<h1><span>Eat n Smile</span></h1>
<form>
<input type="search" name="" placeholder="What do you want??">
<button>Search</button>
</form>
</div>
</div>
</div>
</body>
</html>

Menu.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Today's Menu</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="food-menu">
<div class="container">
<h2 class="text-center">Today's Menu</h2>
<div class="food-menu-box">
<div class="food-menu-img">
<img src="images/menu-chessepizza.png" alt="Cheese Pizza">
</div>
<div class="food-menu-desc">
<h4>Cheese Pizza</h4>
<p class="food-price">₹ 200</p>
<p class="food-detail">
Italian Sauce, Mozzarella Cheese, and Cheddar Cheese
</p>
<a href="#" class="btn btn-primary">Order Now</a>
</div>
</div>
<div class="food-menu-box">
<div class="food-menu-img">
<img src="images/menu-chesseburger.jpg" alt="Cheese Burger">
</div>
<div class="food-menu-desc">
<h4>Cheese Burger</h4>
<p class="food-price">₹ 150</p>
<p class="food-detail">
Mozzarella Cheese, Fresh Vegetables, and Secret Sauce
</p>
<a href="#" class="btn btn-primary">Order Now</a>
</div>
</div>
<div class="food-menu-box">
<div class="food-menu-img">
<img src="images/menu-frenchfries.jpg" alt="Fries">
</div>
<div class="food-menu-desc">
<h4>Fries</h4>
<p class="food-price">₹ 100</p>
<p class="food-detail">
Crispy French Fries
</p>
<a href="#" class="btn btn-primary">Order Now</a>
</div>
</div>
<!-- Add more menu items here -->
</div>
</section>
</body>
</html>

Style.css
/* General styles */ margin: 0;
body { padding: 0;
font-family: Arial, sans-serif;
background-color: #f7f7f7; .navbar ul li:first-child {
} margin-left: 0;
}
.container {
max-width: 1200px; .navbar ul li a {
margin: auto; color: #fff;
padding: 20px; text-decoration: none;
} }

/* Navbar styles */ .navbar ul li a:hover {


.navbar { text-decoration: underline;
background-color: #333; }
color: #fff;
padding: 20px; /* Content styles */
text-align: center; .content {
} text-align: center;
margin-top: 50px;
.navbar h1 { }
margin: 0;
} .welcome-section h3 {
font-size: 24px;
.navbar ul { color: #333;
list-style-type: none; }
padding: 0;
margin: 0; .welcome-section h1 {
} font-size: 48px;
margin: 20px 0;
.navbar ul li { }
display: inline;
margin-left: 20px; .welcome-section span {
} color: #ff6347; /* Tomato color */
} padding: 0;
font-family: Arial, sans-serif;
.welcome-section form { background-color: #f7f7f7;
margin-top: 20px; }
}
.container {
.welcome-section input[type="search"] { max-width: 1200px;
padding: 10px; margin: auto;
width: 300px; padding: 20px;
border: 1px solid #ccc; }
border-radius: 5px;
font-size: 16px; .text-center {
} text-align: center;
}
.welcome-section button {
padding: 10px 20px; /* Food Menu Styles */
background-color: #ff6347; /* Tomato color .food-menu {
*/
padding: 50px 0;
color: #fff;
}
border: none;
border-radius: 5px;
.food-menu-box {
cursor: pointer;
display: flex;
font-size: 16px;
flex-wrap: wrap;
}
justify-content: space-between;
margin-top: 30px;
.welcome-section button:hover {
}
background-color: #cc4c3e; /* Darker shade
of Tomato */
.food-menu-box .food-menu-img {
}
flex: 0 0 40%;
max-width: 40%;
/* General Styles */
}
body {
margin: 0;
.food-menu-box .food-menu-img img { text-decoration: none;
width: 100%; padding: 10px 20px;
height: auto; border-radius: 5px;
border-radius: 5px; transition: background-color 0.3s ease;
} }

.food-menu-box .food-menu-desc { .btn:hover {


flex: 0 0 55%; background-color: #cc4c3e; /* Darker shade
of Tomato */
max-width: 55%;
}
}

.food-menu-box h4 {
font-size: 24px;
margin-top: 0;
margin-bottom: 10px;
}

.food-price {
color: #ff6347; /* Tomato color */
font-weight: bold;
margin: 0;
}

.food-detail {
margin-top: 0;
margin-bottom: 20px;
}

.btn {
display: inline-block;
background-color: #ff6347; /* Tomato color
*/
color: #fff;
Output:
Practical 3
Code:
Employee.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="employee.xsl"?>
<!DOCTYPE company SYSTEM "employee.dtd">
<company>
<employee>
<username>Akash123</username>
<password>akash123</password>
<firstname>Akash</firstname>
<lastname>Mete</lastname>
<gender>Male</gender>
<email>akashmete129@gmail.com</email>
<position>Software Developer</position>
<salary>9.5lpa</salary>
<contact>+91 7051794388</contact>
</employee>
<employee>
<username>AlexWest</username>
<password>alex123</password>
<firstname>Alex</firstname>
<lastname>West</lastname>
<gender>Female</gender>
<email>alex123@gmail.com</email>
<position>Software Developer</position>
<salary>8.5lpa</salary>
<contact>+91 9335784511</contact>
</employee>
<employee>
<username>BarryAllen</username>
<password>barry123</password>
<firstname>Barry</firstname>
<lastname>Allen</lastname>
<gender>Male</gender>
<email>barryallen@gmail.com</email>
<position>Frontend Developer</position>
<salary>7.5lpa</salary>

<contact>+91 7834918230</contact>
</employee>
<employee>
<username>JohnDoe</username>
<password>johndoe123</password>
<firstname>John</firstname>
<lastname>Doe</lastname>
<gender>Male</gender>
<email>johndoe@example.com</email>
<position>Marketing Manager</position>
<salary>12lpa</salary>
<contact>+91 9934671209</contact>
</employee>
<employee>
<username>JaneSmith</username>
<password>janesmith456</password>
<firstname>Jane</firstname>
<lastname>Smith</lastname>
<gender>Female</gender>
<email>janesmith@example.com</email>
<position>Human Resources Manager</position>
<salary>10lpa</salary>
<contact>+91 9091293801</contact>
</employee>
<employee>
<username>BobJohnson</username>
<password>bob123</password>
<firstname>Bob</firstname>
<lastname>Johnson</lastname>
<gender>Male</gender>
<email>bob.johnson@example.com</email>
<position>Software Engineer</position>
<salary>9lpa</salary>
<contact>+91 7722012983</contact>
</employee>
</company>

Employee.dtd
<!ELEMENT company (employee+)>
<!ELEMENT employee
(username,password,firstname,lastname,gender,email,position,salary,contact)>
<!ELEMENT username (#PCDATA)>
<!ELEMENT password (#PCDATA)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT gender (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT position (#PCDATA)>
<!ELEMENT salary (#PCDATA)>
<!ELEMENT contact (#PCDATA)>

Employee.xsl
<?xml version="1.0" encoding="UTF-8"?> </head>
<xsl:stylesheet version="1.0" <body>
xmlns:xsl="http://www.w3.org/1999/XSL/Tra
<style>
nsform">
table {
<xsl:template match="/">
border-collapse: collapse;
<html>
width: 100%;
<head>
}
<title>XML-14K15A0501</title>
th { <th>First Name</th>
font-size: 18px; <th>Last Name</th>
color: blue; <th>Gender</th>
border: 1px solid black; <th>Email</th>
<th>Position</th>
padding: 8px; <th>Salary</th>
text-align: left; <th>Contact</th>
} </tr>
tr:nth-child(even) { <xsl:for-each select="company/employee">
background-color: #f2f2f2; <tr>
} <td>
th:hover{ <xsl:value-of select="username" />
background-color: black; </td>
color:white; <td>
} <xsl:value-of select="password" />
tr:hover { </td>
background-color: black; <td>
color:white; <xsl:value-of select="firstname" />
} </td>
td { <td>
border: 1px solid black; <xsl:value-of select="lastname" />
padding: 8px; </td>
vertical-align: top; <td>
} <xsl:value-of select="gender" />
td.salary { </td>
text-align: right; <td>
} <xsl:value-of select="email" />
</style> </td>
<table> <td>
<tr>
<th>Username</th> <xsl:value-of select="position" />
<th>Password</th> </td>
<td class="salary"> </xsl:for-each>
₹<xsl:value-of select="salary"/> </table>
</td> </body>
<td> </html>
<xsl:value-of select="contact" /> </xsl:template>
</td> </xsl:stylesheet>
</tr>

Output:
Practical 4
Code:
Index.html
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>Assignment 4</title>
</head>

<body>
<div class="container">
<h1>Calculator</h1>

<div class="calculator">
<input type="text" name="screen" id="screen">
<table>
<tr>
<td><button>(</button></td>
<td><button>)</button></td>
<td><button>C</button></td>
<td><button>%</button></td>
</tr>
<tr>
<td><button>7</button></td>
<td><button>8</button></td>
<td><button>9</button></td>
<td><button>X</button></td>
</tr>
<tr>
<td><button>4</button></td>
<td><button>5</button></td>
<td><button>6</button></td>
<td><button>-</button></td>
</tr>
<tr>
<td><button>1</button></td>
<td><button>2</button></td>
<td><button>3</button></td>
<td><button>+</button></td>
</tr>
<tr>
<td><button>0</button></td>
<td><button>.</button></td>
<td><button>/</button></td>
<td><button>=</button></td>
</tr>
</table>
</div>
</div>

</body>
<script src="index.js"></script>

</html>

Style.css
.container{ }
text-align: center; table{
margin-top:23px margin: auto;
} margin: 6px;
input{ }
border-radius: 21px; .calculator{
border: 5px solid #dce0dc; border: 4px solid #000000;
font-size:34px; background-color: #beb8be;
height: 65px; padding: 23px;
width: 456px; border-radius: 40px;
} display: inline-block;
button{ }
border-radius: 10px; h1{
font-size: 30px; font-size: 28px;
background: #978fa0; font-family: Cambria, Cochin, Georgia,
Times, 'Times New Roman', serif;
width: 102px;
}
height: 90px;
Index.js
let screen = screen.value = screenValue;
document.getElementById('screen');
}
buttons = document.querySelectorAll('button');
else if (buttonText == '=') {
let screenValue = '';
screen.value = eval(screenValue);
for (item of buttons) {
}
item.addEventListener('click', (e) => {
else {
buttonText = e.target.innerText;
screenValue += buttonText;
console.log('Button text is ', buttonText);
screen.value = screenValue;
if (buttonText == 'X') {
}
buttonText = '*';
screenValue += buttonText;
})
screen.value = screenValue;
}
}
else if (buttonText == 'C') {
screenValue = "";
Output:
Practical 5
Register.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Registration Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
form {
max-width: 500px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
h1 {
text-align: center;
color: #444444;
}
h2 {
text-align: center;
color: #444444;
}
input[type="number"],
input[type="text"],
input[type="submit"] {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border-radius: 3px;
box-sizing: border-box;
font-size: 16px;
border: 2px solid #cccccc;
border-radius: 5px;
padding: 10px;
}
input[type="submit"] {
background-color: #4CAF50;
color: #ffffff;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #3e8e41;}
</style>
</head>
<body>
<h1>Registration Form</h1>
<form action="register" method="post">
<label for="book_id">Book ID:</label>

<input type="number" name="book_id" required>


<label for="book_title">Book Title:</label>
<input type="text" name="book_title" required>
<label for="book_author">Book Author:</label>
<input type="text" name="book_author" required>
<label for="book_price">Book Price:</label>
<input type="number" name="book_price" required>
<label for="quantity">Quantity:</label>
<input type="number" name="quantity" required>
<input type="submit" value="Register">
</form>
</body>
</html>

Register.java
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/* * Servlet implementation class Register*/
@WebServlet("/register")
public class register extends HttpServlet {
private static final long serialVersionUID = 1L;
/* * @see HttpServlet#HttpServlet()*/
public register() {
super();
// TODO Auto-generated constructor stub
}
/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String book_id = request.getParameter("book_id");
String book_title = request.getParameter("book_title");
String book_author = request.getParameter("book_author");
String book_price = request.getParameter("book_price");
String quantity = request.getParameter("quantity");
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/BookDB", "root",
"root");
PreparedStatement ps = con.prepareStatement("insert into ebookshop values(?,?,?,?,?)");
ps.setString(1, book_id);
ps.setString(2, book_title);
ps.setString(3, book_author);
ps.setString(4, book_price);
ps.setString(5, quantity);
int i = ps.executeUpdate();
if (i > 0) {
PreparedStatement ps1 = con.prepareStatement("SELECT * FROM ebookshop");

ResultSet rs = ps1.executeQuery();
out.println("<html><head><title>Book Inventory</title>");
out.println("<style>");
out.println("table {border-collapse: collapse; width: 100%;}");
out.println("th, td {text-align: left; padding: 8px;}");
out.println("th {background-color: #4CAF50; color: white;}");
out.println("tr:nth-child(even) {background-color: #f2f2f2;}");
out.println("</style>");
out.println("</head><body>");
out.println("<h2 style=\"text-align: center;\">Book Inventory</h2>");
out.println("<table>");
out.println("<tr><th>ID</th><th>Title</th><th>Author</th><th>Price</th><th>
Quantity</th></tr>");
while (rs.next()) {
book_id = rs.getString("book_id");
book_title = rs.getString("book_title");
book_author = rs.getString("book_author");
book_price = rs.getString("book_price");
quantity = rs.getString("quantity");
out.println("<tr><td>" + book_id + "</td><td>" + book_title + "</td><td>" + book_author +
"</td><td>" + book_price + "</td><td>" + quantity + "</td></tr>");
}
out.println("</table>");
out.print("<h3 style=\"text-align: center; color: red\">You're data has been stored
successfully</h3>");
out.println("</body></html>");
rs.close();
ps1.close();
con.close();
}
} catch (Exception e) {
System.out.println(e);
}
}
}
Output:
Practical 6
Code:
Student.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-
8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Student Registration Form</title>
<style>
/* CSS styles for the form go here */
/* Styles for the form */
form {
max-width: 500px;
margin: 0 auto;
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f5f5f5;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
}
h1 {
text-align: center;
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"], input[type="number"], input[type="submit"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 20px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #e6b225;
color: black;
border: none;
cursor: pointer;
font-size: 16px;
margin-top: 20px;
}
input[type="submit"]:hover {
background-color: #fcba03;
}
</style>
</head>
<body>
<h1>Student Registration Form</h1>
<form action="studentinsert.jsp" method="post">
<label for="student_id">Student ID:</label>
<input type="number" id="student_id" name="student_id" required><br>
<label for="student_name">Student Name:</label>
<input type="text" id="student_name" name="student_name" required><br>
<label for="class_Name">Class:</label>
<input type="text" id="class_Name" name="class_Name" required><br>
<label for="division">Division:</label>
<input type="text" id="division" name="division" required><br>
<label for="city">City:</label>
<input type="text" id="city" name="city" required><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Studentinsert.jsp
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Students Information</title>
<style>
table {border-collapse: collapse; width: 100%;}
th, td {text-align: left; padding: 8px;}
th {background-color: #4CAF50; color: white;}
tr:nth-child(even) {background-color: #f2f2f2;}
</style>
</head>
<body>
<%
String student_id = request.getParameter("student_id");
String student_name = request.getParameter("student_name");
String class_Name = request.getParameter("class_Name");
String division = request.getParameter("division");
String city = request.getParameter("city");
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/student", "root",
"root");
PreparedStatement ps = con.prepareStatement("insert into student_info values(?,?,?,?,?)");
ps.setString(1, student_id);
ps.setString(2, student_name);
ps.setString(3, class_Name);
ps.setString(4, division);
ps.setString(5, city);
int i = ps.executeUpdate();
if (i > 0) {
PreparedStatement ps1 = con.prepareStatement("SELECT * FROM student_info");
ResultSet rs = ps1.executeQuery();
%>
<h2 style="text-align: center;">STUDENTS INFORMATION</h2>
<table>
<tr><th>ID</th><th>NAME</th><th>CLASS</th><th>DIVISION</th><th>CITY</th></
tr>
<%
while (rs.next()) {
student_id = rs.getString("student_id");
student_name = rs.getString("student_name");
class_Name = rs.getString("class_Name");
division = rs.getString("division");
city = rs.getString("city");
%>
<tr><td><%= student_id %></td><td><%= student_name %></td><td><%= class_Name
%></td><td><%= division %></td><td><%= city %></td></tr>
<%
}
%>
</table>
<h3 style="text-align: center; color: red">Your data has been stored successfully</h3>
<%
rs.close();
ps1.close();
}
con.close();
} catch (Exception e) {
out.println(e);
}
%>
</body>
</html>

Output:
Practical 7
Code:
Index.php
<!doctype html> $retval = mysqli_query($conn, $sql);
<html lang="en"> ?>
<head> <!--Navbar-->
<!-- Required meta tags --> <nav class="navbar navbar-expand-lg navbar-
dark bg-dark">
<meta charset="utf-8">
<a class="navbar-brand text-success"
<meta name="viewport"
style="font-weight:bold;">Student
content="width=device-width, initial-scale=1,
Database</a>
shrink-to-fit=no">
<button class="navbar-toggler" type="button"
<!-- Bootstrap CSS -->
data-toggle="collapse" data-
<link rel="stylesheet" target="#navbarText" aria-
href="https://cdn.jsdelivr.net/npm/bootstrap@
controls="navbarText" aria-expanded="false"
4.6.1/dist/css/bootstrap.min.css"
aria-label="Toggle navigation">
integrity="sha384-
<span class="navbar-toggler-icon"></span>
zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAu
ZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" </button>
crossorigin="anonymous"> <div class="collapse navbar-collapse"
id="navbarText">
<title>PHP CRUD OPERATIONS</title>
<ul class="navbar-nav mr-auto">
</head>
<li class="nav-item active">
<body>
<a class="nav-link" href="index.php">Home
<?php
<span class="sr-only">(current)</span></a>
//for sql connection
</li>
$host = 'localhost:3306';
</ul>
$user = 'root';
<td><button type="button" data-
$pass = 'root'; toggle="modal" data-target="#exampleModal"
class="btn btn-
$dbname = 'student';
outline-success" >Add</button></td>
$conn = mysqli_connect($host, $user, $pass,
$dbname); </div>

if (!$conn) { </nav>

die('Could not connect: ' . <!---->


mysqli_connect_error());
<div class="container mt-2">
}
<table class="table table-bordered">
$sql = "SELECT * FROM studentdata";
<thead class="thead-dark">
<tr> echo "<div class='alert alert-warning alert-
dismissible fade show' role='alert'>
<th scope="col">student Id</th>
<strong>Data Not Found!</strong>
<th scope="col">Roll No</th>
<button type='button' class='close' data-
<th scope="col">Name</th>
dismiss='alert' aria-label='Close'>
<th scope="col">Class(FE,TE,BE)</th>
<span aria-hidden='true'>&times;</span>
<th scope="col">Address</th>
</button>
<th scope="col">Update</th>
</div>";
<th scope="col">Delete</th>
}
</tr>
?>
</thead>
</tbody>
<tbody>
</table>
<?php
</div>
if (mysqli_num_rows($retval) > 0) {
<!--Add-->
while ($row = mysqli_fetch_assoc($retval)) {
<div class="modal fade" id="exampleModal"
?> tabindex="-1" aria-
labelledby="exampleModalLabel"
<tr> ariahidden="true">
<td><?php echo $row['id'] ?? ''; ?></td> <div class="modal-dialog">
<td><?php echo $row['rollno']; ?></td> <div class="modal-content">
<td><?php echo $row['name']; ?></td> <div class="modal-header">
<td><?php echo $row['class']; ?></td> <h5 class="modal-title"
<td><?php echo $row['address']; ?></td> id="exampleModalLabel">Add Student</h5>

<td><button type="button" data- <button type="button" class="close" data-


toggle="modal" data- dismiss="modal" aria-label="Close">
target="#exampleModal2" <span aria-hidden="true">&times;</span>
class="btn btn-outline-success" </button>
>Update</button></td>
</div>
<td><button type="button" data-
toggle="modal" data- <div class="modal-body">
target="#exampleModal1"
<form action="Add.php" method="post">
class="btn btn-outline-success"
<div class="form-group">
>Delete</button></td>
<label for="recipient-name" class="col-form-
</tr>
label">ID:</label>
<?php }
<input type="number" class="form-control"
} else { name="id">
</div> </div>
<div class="form-group"> <!--update-->
<label for="recipient-name" class="col-form- <div class="modal fade"
label">Roll Number:</label> id="exampleModal2" tabindex="-1" aria-
labelledby="exampleModalLabel"
<input type="number" class="form-control"
ariahidden="true">
name="roll">
<div class="modal-dialog">
</div>
<div class="modal-content">
<div class="form-group">
<div class="modal-header">
<label for="recipient-name" class="col-form-
label">Name:</label> <h5 class="modal-title"
id="exampleModalLabel">Update
<input type="text" class="form-control"
Student</h5>
name="name">
<button type="button" class="close" data-
</div>
dismiss="modal" aria-label="Close">
<div class="form-group">
<span aria-hidden="true">&times;</span>
<label for="recipient-name" class="col-form-
</button>
label">Class:</label>
</div>
<input type="text" class="form-control"
name="class"> <div class="modal-body">
</div> <form action="update.php" method="post">
<div class="form-group"> <div class="form-group">
<label for="recipient-name" class="col-form- <label for="recipient-name" class="col-form-
label">Address:</label> label">ID:</label>
<input type="text" class="form-control" <input type="number" class="form-control"
name="address"> name="id">
</div> </div>
<button type="submit" class="btn btn- <div class="form-group">
primary" name="adminlogin">Add
<label for="recipient-name" class="col-form-
Student</button>
label">Roll Number:</label>
</form>
<input type="number" class="form-control"
</div> name="roll">
<div class="modal-footer"> </div>
<button type="button" class="btn btn- <div class="form-group">
secondary"
<label for="recipient-name" class="col-form-
data-dismiss="modal">Close</button>
label">Name:</label>
</div>
<input type="text" class="form-control"
</div> name="name">
</div> </div>
<div class="form-group"> <span aria-hidden="true">&times;</span>
<label for="recipient-name" class="col-form- </button>
label">Class:</label>
</div>
<input type="text" class="form-control"
<div class="modal-body">
name="class">
<form action="delete.php" method="post">
</div>
<div class="form-group">
<div class="form-group">
<label for="recipient-name" class="col-form-
<label for="recipient-name" class="col-form-
label">ID:</label>
label">Address:</label>
<input type="number" class="form-control"
<input type="text" class="form-control"
name="id">
name="address">
</div>
</div>
<button type="submit" class="btn btn-
primary" name="adminlogin">Add <button type="submit" class="btn btn-
Student</button> primary"
name="adminlogin">Delete</button>
</form>
</form>
</div>
</div>
<div class="modal-footer">
<div class="modal-footer">
<button type="button" class="btn btn-
secondary" <button type="button" class="btn btn-
data-dismiss="modal">Close</button> secondary"
data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--Delete-->
<script
<div class="modal fade"
src="https://cdn.jsdelivr.net/npm/jquery@3.5.1
id="exampleModal1" tabindex="-1" aria-
/dist/jquery.slim.min.js" integrity="sha384-
labelledby="exampleModalLabel"
ariahidden="true">
DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoF
<div class="modal-dialog">
Vy38MVBnE+IbbVYUew+OrCXaRkfj"
<div class="modal-content">
crossorigin="anonymous"></script>
<div class="modal-header">
<script
<h5 class="modal-title" src="https://cdn.jsdelivr.net/npm/bootstrap@4.
id="exampleModalLabel">Delete</h5> 6.1/dist/js/bootstrap.bundle.min.js"
<button type="button" class="close" data-
dismiss="modal" aria-label="Close">
integrity="sha384- </body>
fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/
</html>
tB9LTS58ONXgqbR9W8oWht/amnpF"
crossorigin="anonymous"></script>

Add.php
<!doctype html> }
<html lang="en"> ?>
<head> <!--Navbar-->
<!-- Required meta tags --> <nav class="navbar navbar-expand-lg navbar-
dark bg-dark">
<meta charset="utf-8">
<a class="navbar-brand text-success"
<meta name="viewport"
style="font-weight:bold;">Student
content="width=device-width, initial-scale=1,
Database</a>
shrink-to-fit=no">
<button class="navbar-toggler" type="button"
<!-- Bootstrap CSS -->
data-toggle="collapse" data-
<link rel="stylesheet" target="#navbarText" aria-
href="https://cdn.jsdelivr.net/npm/bootstrap@
controls="navbarText" aria-expanded="false"
4.6.1/dist/css/bootstrap.min.css"
aria-label="Toggle navigation">
integrity="sha384-
<span class="navbar-toggler-icon"></span>
zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAu
ZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" </button>
crossorigin="anonymous"> <div class="collapse navbar-collapse"
id="navbarText">
<title>PHP CRUD OPERATIONS</title>
<ul class="navbar-nav mr-auto">
</head>
<li class="nav-item active">
<body>
<a class="nav-link" href="index.php">Home
<?php
<span class="sr-only">(current)</span></a>
//for sql connection
</li>
$host = 'localhost:3306';
</ul>
$user = 'root';
</div>
$pass = 'root';
</nav>
$dbname = 'student';
<div class="container-fluid">
$conn = mysqli_connect($host, $user, $pass,
<?php
$dbname);
// Taking all 5 values from the form
if (!$conn) {
data(input)
die('Could not connect: ' .
$name = $_REQUEST['name'];
mysqli_connect_error());
$id = $_REQUEST['id']; </div> ";
$roll = $_REQUEST['roll']; }
$class = $_REQUEST['class']; // Close connection
$address= $_REQUEST['address']; mysqli_close($conn);
// Performing insert query execution ?>
$sql = "INSERT INTO studentdata VALUES </div>
('$id','$roll','$name','$class','$address')";
<script
if(mysqli_query($conn, $sql)){ src="https://cdn.jsdelivr.net/npm/jquery@3.5.1
/dist/jquery.slim.min.js" integrity="sha384-
echo "<div class='alert alert-success'
role='alert'> DfXdz2htPH0lsSSs5nCTpuj/
zy4C+OGpamoFVy38MVBnE+IbbVYUew+
Add Successful Thank you !
OrCXaRkfj"
<a href='Index.php'> <button type='submit'
crossorigin="anonymous"></script>
class='btn btn-success'>Back To
Home</button></a> <script
src="https://cdn.jsdelivr.net/npm/bootstrap@4.
</div>";
6.1/dist/js/bootstrap.bundle.min.js"
}else{
integrity="sha384-
echo "<div class='alert alert-danger' fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/
role='alert'> tB9LTS58ONXgqbR9W8oWht/amnpF"

Try Again Something went wrong ! May crossorigin="anonymous"></script>


Already Register
</body>
<a href='Index.php'> <button type='submit'
</html
class='btn btn-success'>Back To
Home</button></a>
Output:
Practical 8
Code:
Struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="LoginForm" type="com.example.struts.LoginForm"/>
</form-beans>
<action-mappings>
<action path="/login" type="com.example.struts.LoginAction" name="LoginForm"
validate="true" input="/login.jsp">
<forward name="success" path="/success.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.example.struts.ApplicationResources"/>
</struts-config>
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/webapp_3_1.xsd">
<filter>
<filter-name>Login Validation</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

LoginAction.java
package com.myapp.struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts.action.ActionMessage;
public class LoginAction extends ActionSupport {

private String name;


private String mobileno;
private String email;
public String getMobileno() {
return mobileno;
}
public void setMobileno(String mobileno) {
this.mobileno = mobileno;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}

public String getName() {


return name;
}
public void setName(String string) {
name = string;
}
public LoginAction() {
super();
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (name == null || name.trim().equals("")) {
errors.add("name", new ActionMessage("error.name.required"));
} else if (!name.matches("[a-zA-Z ]+")) {
errors.add("name", new ActionMessage("error.name.invalid"));
}
if (mobileno == null || mobileno.trim().equals("")) {
errors.add("mobile", new ActionMessage("error.mobile.required"));
} else if (!mobileno.matches("\\d{10}")) {
errors.add("mobile", new ActionMessage("error.mobile.invalid"));
}
if (email == null || email.trim().equals("")) {
errors.add("email", new ActionMessage("error.email.required"));
} else if (!email.matches("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}")) {
errors.add("email", new ActionMessage("error.email.invalid"));
}
return errors;
}
}

Login.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Page</title>
</head>
<body style="margin-left: 40%; margin-top: 10%">
<h1>Login Form</h1>
<s:form action="login_action">
<s:textfield name="name" label="Enter your Name: "/>
<s:textfield name="mobileno" label="Enter your Mobile No: "/>
<s:textfield name="email" label="Enter your Email: "/>
<s:submit value="Login" align="center"/>
</s:form>
</body>
</html>

Output:
Practical 9
Code:
Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Assignment-9</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="app.js"></script>
</head>
<body>
<div ng-app = "myApp" class = "container" style="width:550px">
<div style="text-align:center;color:rgb(15, 15, 15);background-color: rgb(202, 226, 248);">
<h3><b>Registraion Form</b></h3>
</div>
<div ng-controller = "ContactController">
<div align="right">
<a href="#" ng-click="searchUser()">{{title}}</a>
</div>
<form role = "form" class="well" ng-hide="ifSearchUser">
<div class = "form-group">
<label for = "name"> Name: </label>
<input type = "text" id = "name" class = "form-control" placeholder = "Enter
Name " ng-model = "newcontact.name">
</div>
<div class = "form-group">
<label for = "email"> Email: </label>
<input type = "email" id = "email" class = "form-control" placeholder = "Enter
Email " ng-model = "newcontact.email">
</div>
<div class = "form-group">
<label for = "password"> Password: </label>
<input type = "password" id = "password" class = "form-control" placeholder
= "Enter Password " ng-model = "newcontact.password">
</div>
<div class = "form-group">
<label for = "phone"> Phone: </label>
<input type = "text" id = "phone" class = "form-control" placeholder = "Enter
Phone " ng-model = "newcontact.phone">
</div>
<div class = "form-group">
<label for = "age"> Age: </label>
<input type = "text" id = "age" class = "form-control" placeholder = "Enter
Age " ng-model = "newcontact.age">
</div>
<br>
<input type="hidden" ng-model="newcontact.id">
<input type="button" class="btn btn-primary" ng-click="saveContact()" class="btn
btn-primary" value = "Submit">
</form>
<div><h4><b>Registered Users</b></h4>
<table ng-if="contacts.length" class = "table table-striped table-bordered table-
hover">
<thead>
<tr class = "info">
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Age</th>
<th ng-if="!ifSearchUser">Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat = "contact in contacts">
<td>{{ contact.name }}</td>
<td>{{ contact.email }}</td>
<td>{{ contact.phone }}</td>
<td>{{ contact.age }}</td>
<td ng-if="!ifSearchUser">
<a href="#" ng-click="edit(contact.id)" role = "button" class = "btn btn-
info">edit</a> &nbsp;
<a href="#" ng-click="delete(contact.id)" role = "button" class = "btn btn
-danger">delete</a>
</td>
</tr>
</tbody>
</table>
<div ng-hide="contacts.length > 0">No Users Found</div>
</div>
</div>
</div>
</body> </html>

App.js
var myApp = angular.module("myApp", []); 'phone' : '7821923100',
myApp.service("ContactService" , function(){ 'age' : '20'}];
var uid = 1; this.save = function(contact)
var contacts = [{ {
'id' : 0, if(contact.id == null)
'name' : 'Soham Rajput', { contact.id = uid
'email' : 'sohamrjp@gmail.com', contacts.push(contact);
'password': 'Soham@112', }
else $scope.contacts = ContactService.list();
{ for(var i in contacts) $scope.saveContact = function()
{ if(contacts[i].id == contact.id) {
{ contacts[i] = contact; console.log($scope.newcontact);
} if($scope.newcontact == null ||
$scope.newcontact == angular.undefined)
}
return;
}
ContactService.save($scope.newcontact);
};
$scope.newcontact = {};
this.get = function(id)
};
{ for(var i in contacts )
$scope.delete = function(id)
{ if( contacts[i].id == id)
{
{ return contacts[i];
ContactService.delete(id);
}
if($scope.newcontact != angular.undefined
}
&& $scope.newcontact.id == id)
};
{
this.delete = function(id)
$scope.newcontact = {};
{ for(var i in contacts)
}
{ if(contacts[i].id == id)
};
{ contacts.splice(i,1);
$scope.edit = function(id)
}
{
}
$scope.newcontact =
}; angular.copy(ContactService.get(id));

this.list = function() };

{ return contacts; $scope.searchUser = function(){

}; if($scope.title == "List of Users"){

}); $scope.ifSearchUser=true;

myApp.controller("ContactController" , $scope.title = "Back";


function($scope , ContactService){
}
console.clear();
else
{
$scope.ifSearchUser = false;
$scope.ifSearchUser = false;
$scope.title ="List of Users";
$scope.title = "List of Users";
} });
};

Output:
Practical 10
Code:
Index.html
<html>
<head>
<title>Implement Bank Application using EJB</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="post" action="transact">
<h1>Bank Application using EJB </h1>
Enter Amount : <input type="text" name="t1" />
<h3>Select option</h3>
<input type="radio" name="transaction"value="deposite" />Deposite<br/>
<input type="radio" name="transaction"value="withdraw" />withdraw<br/>
<input type="submite" value="submite" />
</form>
</body>
</html>

Transact.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class transact extends httpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8");
try
{
PrintWriter out = response.getWriter()};
String selectdType=request.getParameter("transact");
int amount=Integer.ParseInt(request.getParameter(t1));
if(selectdType.equals("deposite"))
{
bankTransact.deposite(amount);
}
if(selectdType.equals("withdraw"))
{
int amt=bankTransact.withdraw(amount);
out.println(amount="successfully withdraw. Your Balance is: Rs"+ amt)
}
}
}
private BankTransactLocal lookupBankTransactLocal()
{
try
{
Context c= New initialContext();
return(BankTransactLocal)c.Lookup("java.global/Bank/Bank-ejb/BankTransact!Bankexamp.Bank/
Bank-
ejb/BankTransactLocal")
}
catch (NamingException ne)
{
Logger.getLogger(getClass().getName().log(Level.SEVERE,"exception caught",ne))
throw new RuntimeException(ne);
}
}

BankTransact.java
package bankexamp;
inport javax.ejb.Statful;
@Stateful
public class BankTransact implements BankTransactLocal{
int balance=10000;
@override
public int deposit (int amount){
balance=balance+amount;
return balance;
}
@override
public int withdraw (int amount){
balance=balance-amount
return balance;
}
}

Output:

You might also like