0% found this document useful (0 votes)
12 views

OUTPUT AI-flat

The document outlines practical exercises involving web development and programming, including creating a restaurant website with HTML, CSS, and JavaScript, designing an XML document for employee information with DTD and XML Schema, implementing a JavaScript calculator, and demonstrating servlet usage with a database. Each practical includes specific requirements such as form design, input validation, and data display. The document serves as a comprehensive guide for students to apply various programming and web development concepts.

Uploaded by

naitikpawar22
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)
12 views

OUTPUT AI-flat

The document outlines practical exercises involving web development and programming, including creating a restaurant website with HTML, CSS, and JavaScript, designing an XML document for employee information with DTD and XML Schema, implementing a JavaScript calculator, and demonstrating servlet usage with a database. Each practical includes specific requirements such as form design, input validation, and data display. The document serves as a comprehensive guide for students to apply various programming and web development concepts.

Uploaded by

naitikpawar22
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/ 44

Practical No:-2

Implement a web page index.htm for any client website (e.g., a restaurant website project)
using following: a. HTML syntax: heading tags, basic tags and attributes, frames, tables,
images, lists, links for text and images, forms etc. b. Use of Internal CSS, Inline CSS, External
CSS.

Login.html:-

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Login | TastyBite</title>

<!-- Bootstrap CSS -->

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">

<link rel="stylesheet" href="form-style.css">

<style> body {

background: #f2f2f2;

</style>

</head>

<body>

<div class="container">

<div class="form-box shadow p-4 mt-5 bg-white rounded">

<h2 class="text-center text-danger mb-4">Login</h2>

<form>

<div class="mb-3">

<label class="form-label">Email address</label>

<input type="email" class="form-control" placeholder="Enter email"> </div>

<div class="mb-3">

<label class="form-label">Password</label>

<input type="password" class="form-control" placeholder="Enter password"> </div>


<button type="submit" class="btn btn-danger w-100">Login</button>

<p class="text-center mt-3">Don't have an account? <a href="register.html">Register</a></p>

</form>

</div>

</div>

<!-- Bootstrap JS -->

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

</body>

</html>

Register.html:- <!DOCTYPE

html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Register | TastyBite</title>

<!-- Bootstrap CSS -->

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">

<link rel="stylesheet" href="form-style.css">

<style> body {

background: #f2f2f2;

</style>

</head>

<body>

<div class="container">

<div class="form-box shadow p-4 mt-5 bg-white rounded">

<h2 class="text-center text-danger mb-4">Register</h2>

<form>

<div class="mb-3">
<label class="form-label">Full Name</label>

<input type="text" class="form-control" placeholder="Enter name"> </div>

<div class="mb-3">

<label class="form-label">Email address</label>

<input type="email" class="form-control" placeholder="Enter email"> </div>

<div class="mb-3">

<label class="form-label">Password</label>

<input type="password" class="form-control" placeholder="Create password">

</div>

<div class="mb-3">

<label class="form-label">Confirm Password</label>

<input type="password" class="form-control" placeholder="Confirm password">

</div>

<button type="submit" class="btn btn-danger w-100">Register</button>

<p class="text-center mt-3">Already have an account? <a href="login.html">Login</a></p>

</form>

</div>

</div>

<!-- Bootstrap JS -->

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

</body>

</html>

form-style.css:- .form-box {

max-width: 400px; margin:

auto; border: 1px solid

#dee2e6; border-radius:

15px;

input:focus { border-color: #dc3545 !important; box-

shadow: 0 0 5px rgba(220, 53, 69, 0.5) !important;

}
OUTPUT
Practical No:- 3

Design the XML document to store the information of the employees of any business organization
and demonstrate the use of: a) DTD b) XML Schema And display the content in (e.g., tabular
format) by using CSS/XSL.

employees.dtd:-

<!ELEMENT employees (employee+)>

<!ELEMENT employee (id, name, designation, department, salary)>

<!ELEMENT id (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT designation (#PCDATA)>

<!ELEMENT department (#PCDATA)>

<!ELEMENT salary (#PCDATA)>

employees.xml:-

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

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

<!DOCTYPE employees SYSTEM "employees.dtd">

<employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="employees.xsd">

<employee>

<id>101</id>

<name>Rahul Sharma</name>

<designation>Software Engineer</designation>

<department>IT</department>

<salary>60000</salary>

</employee>

<employee>

<id>102</id>

<name>Priya Verma</name>

<designation>HR Manager</designation>

<department>HR</department>

<salary>75000</salary>

</employee>
<employee>

<id>103</id>

<name>Amit Joshi</name>

<designation>Accountant</designation>

<department>Finance</department>

<salary>55000</salary>

</employee>

</employees>

employees.xsd:-

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

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="employees">

<xs:complexType>

<xs:sequence>

<xs:element name="employee" maxOccurs="unbounded">

<xs:complexType>

<xs:sequence>

<xs:element name="id" type="xs:int"/>

<xs:element name="name" type="xs:string"/>

<xs:element name="designation" type="xs:string"/>

<xs:element name="department" type="xs:string"/>

<xs:element name="salary" type="xs:decimal"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>
employees.xsl:-

<?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>

<head>

<title>Employee Details</title>

<style> body {

font-family: Arial, sans-serif;

padding: 20px;

} table {

border-collapse: collapse;

width: 80%; margin:

auto;

th, td {

border: 1px solid #ccc;

padding: 10px; text-align:

center;

th {

background-color: #f44336;

color: white;

tr:nth-child(even) {

background-color: #f2f2f2;

</style>

</head>

<body>

<h2 style="text-align: center;">Employee List</h2>

<table>
<tr>

<th>ID</th>

<th>Name</th>

<th>Designation</th>

<th>Department</th>

<th>Salary</th>

</tr>

<xsl:for-each select="employees/employee">

<tr>

<td><xsl:value-of select="id"/></td>

<td><xsl:value-of select="name"/></td>

<td><xsl:value-of select="designation"/></td>

<td><xsl:value-of select="department"/></td>

<td>₹<xsl:value-of select="salary"/></td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

OUTPUT
Practical No:- 4

Implement an application in Java Script using following: a) Design UI of application using HTML, CSS
etc. b) Include Java script validation c) Use of prompt and alert window using Java Script e.g., Design
and implement a simple calculator using Java Script for operations like addition, multiplication,
subtraction, division, square of number etc. a) Design calculator interface like text field for input and
output, buttons for numbers and operators etc. b) Validate input values c) Prompt/alerts for invalid
values etc.

index.html:-

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

<title>Modern Calculator</title>

<link rel="stylesheet" href="style.css"/>

</head>

<body>

<div class="calculator">

<input type="text" id="display" readonly />

<div class="buttons">

<button onclick="clearDisplay()">C</button>

<button onclick="append('%')">%</button>

<button onclick="backspace()">←</button>

<button onclick="append('/')">÷</button>

<button onclick="append('7')">7</button>

<button onclick="append('8')">8</button>

<button onclick="append('9')">9</button>

<button onclick="append('*')">×</button>

<button onclick="append('4')">4</button>

<button onclick="append('5')">5</button>

<button onclick="append('6')">6</button>

<button onclick="append('-')">−</button>

<button onclick="append('1')">1</button>

<button onclick="append('2')">2</button>
<button onclick="append('3')">3</button>

<button onclick="append('+')">+</button>

<button onclick="append('0')">0</button>

<button onclick="append('.')">.</button>

<button onclick="calculate()" class="equal">=</button>

</div>

</div>

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

</body> </html> style.css:- * { box-sizing: border-box;

margin: 0; padding: 0; } body { height: 100vh;

background: linear-gradient(135deg, #667eea, #764ba2);

display: flex; justify-content: center; align-items:

center; font-family: "Segoe UI", sans-serif;

} .calculator { background: rgba(255, 255,

255, 0.1); backdrop-filter: blur(15px);

border-radius: 20px; box-shadow: 0 8px

32px rgba(0, 0, 0, 0.2); padding: 20px;

width: 320px;

#display { width: 100%; height: 60px;

font-size: 28px; margin-bottom: 20px; text-

align: right; padding: 10px; border: none;

border-radius: 10px; background: rgba(255,

255, 255, 0.15); color: #fff; outline: none; }

.buttons { display: grid; grid-template-

columns: repeat(4, 1fr); gap: 15px; } button

{ height: 60px; font-size: 22px; border:

none; border-radius: 10px; background-

color: rgba(255, 255, 255, 0.15); color: #fff;

cursor: pointer; transition: all 0.2s ease-in-

out;
} button:hover { background-color:

rgba(255, 255, 255, 0.3); transform:

scale(1.05);

}
.equal { grid-column: span

2; background-color:

#00b894;

} .equal:hover {

background-color: #00a37c;

} script.js:- function append(value) {

document.getElementById("display").value += value;

} function clearDisplay() {

document.getElementById("display").value = "";

} function backspace() { const display =

document.getElementById("display"); display.value =

display.value.slice(0, -1);

} function calculate() { const display =

document.getElementById("display");

try { display.value =

eval(display.value);

} catch { alert("Invalid

expression!"); display.value

= "";

}
OUTPUT
Practical No:- 5

Implement the sample program demonstrating the use of Servlet. e.g., Create a database table eBook shop
(book_id, book_title, book_author, book_price, quantity) using database like Oracle/MySQL etc. and display
(use SQL select query) the table content using servlet.

index.html:-

<!DOCTYPE html>

<html ng-app="app">

<head>

<meta charset="utf-8" />

<title>AngularJS User Registration and Login Example & Tutorial</title>

<link rel="stylesheet" href=

"//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/>

<link href="//cdn.rawgit.com/cornflourblue/angular-registration-login- example/master/app

content/app.css" rel="stylesheet"/>

</head>

<body>

<div class="jumbotron">

<div class="container">

<div class="col-sm-8 col-sm-offset-2">

<div ng-class="{ 'alert': flash, 'alert-success': flash.type ===

'success', 'alert-danger':

flash.type === 'error' }"

ng-if="flash" ng-

bind="flash.message">

</div>

<div ng-view></div>

</div>

</div>

</div>

<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>

<script src="//code.angularjs.org/1.6.0/angular.min.js"></script>

<script src="//code.angularjs.org/1.6.0/angular-route.min.js"></script>

<script src="//code.angularjs.org/1.6.0/angular-cookies.min.js"></script>
<script src="//cdn.rawgit.com/cornflourblue/angular-registration-login example/master/app.js"></script>

<script src="//cdn.rawgit.com/cornflourblue/angular-registration-login- example/master/app

services/authentication.service.js"></script>

<script src="//cdn.rawgit.com/cornflourblue/angular-registration-login- example/master/app

services/flash.service.js"></script>

<script src="//cdn.rawgit.com/cornflourblue/angular-registration-login- example/master/app

services/user.service.local-storage.js"></script>

<script src="//cdn.rawgit.com/cornflourblue/angular-registration-login

example/master/home/home.controller.js"></script>

<script src="//cdn.rawgit.com/cornflourblue/angular-registration-login

example/master/login/login.controller.js"></script>

<script src="//cdn.rawgit.com/cornflourblue/angular-registration-login

example/master/register/register.controller.js"></script>

</body>

</html>

home.view.html:-

<h1>Hi {{vm.user.firstName}}!</h1>

<p>You're logged in!!</p>

<h3>All registered users:</h3>

<ul>

<li ng-repeat="user in vm.allUsers">

{{user.username}} ({{user.firstName}} {{user.lastName}})

- <a ng-click="vm.deleteUser(user.id)">Delete</a>

</li>

</ul>

<p>&nbsp;</p>

<p><a href="#!/login" class="btnbtn-primary">Logout</a></p>

Login.view.html:-

<div class="col-md-6 col-md-offset-3">

<h2>Login</h2>

<form name="form" ng-submit="vm.login()" role="form">


<div class="form-group" ng-class="{ 'has-error': form.username.$dirty&& form.username.$error.required

}">

<label for="username">Username</label>

<input type="text" name="username" id="username" class="form-control" ng- model="vm.username"

required />

<span ng-show="form.username.$dirty&& form.username.$error.required" class="help

block">Username is required</span>

</div>

<div class="form-group" ng-class="{ 'has-error': form.password.$dirty&& form.password.$error.required

}">

<label for="password">Password</label>

<input type="password" name="password" id="password" class="form-control" ng- model="vm.password"

required />

<span ng-show="form.password.$dirty&& form.password.$error.required" class="help- block">Password is

required</span>

</div>

<div class="form-actions">

<button type="submit" ng-disabled="form.$invalid || vm.dataLoading" class="btnbtn

primary">Login</button>

<a href="#!/register" class="btnbtn-link">Register</a>

</div>

</form></div>

app.js:- (function

() {

'use strict';

angular

.module('app', ['ngRoute', 'ngCookies'])

.config(config) .run(run); config.$inject =

['$routeProvider', '$locationProvider']; function

config($routeProvider, $locationProvider) {

$routeProvider
.when('/', { controller:

'HomeController', templateUrl:

'home/home.view.html',

controllerAs: 'vm'

})

.when('/login', { controller:

'LoginController', templateUrl:

'login/login.view.html',

controllerAs: 'vm'

})

.when('/register', { controller:

'RegisterController', templateUrl:

'register/register.view.html',

controllerAs: 'vm'

})

.otherwise({ redirectTo: '/login' });

run.$inject = ['$rootScope', '$location', '$cookieStore', '$http'];

function run($rootScope, $location, $cookieStore, $http) {

// keep user logged in after page refresh

$rootScope.globals = $cookieStore.get('globals') || {};

if ($rootScope.globals.currentUser) {

$http.defaults.headers.common['Authorization'] = 'Basic ' +

$rootScope.globals.currentUser.authdata; // jshintignore:line

$rootScope.$on('$locationChangeStart', function (event, next, current) { //

redirect to login page if not logged in and trying to access a restricted page

var restrictedPage = $.inArray($location.path(), ['/login', '/register']) === -1;

var loggedIn = $rootScope.globals.currentUser; if (restrictedPage&&

!loggedIn) {

$location.path('/login');

});
}

})();

OUTPUT:-
PRACTICLE NO : 6

Implement the program demonstrating the use of JSP. e.g., Create a database table students_info (stud_id,
stud_name, class, division, city) using database like Oracle/MySQL etc. and display (use SQL select
query) the table content using JSP.

Head.html:-

<center>

<h1 style="color: red;">E-BOOK SHOP DATABASE OPERATIONS</h1>

</center>

Menu.html:-

<!DOCTYPE html>

<html>

<body bgcolor="skyblue">

<a href="insert" target="right">INSERT</a><br><br>

<a href="delete" target="right">DELETE</a><br><br>

<a href="update" target="right">UPDATE</a><br><br>

<a href="display" target="right">DISPLAY</a><br><br>

</body>

</html>

Display.html:-

<center>

<h1>WELCOME TO E-BOOK SHOP</h1>

</center>

MainPage.html:-

<frameset rows="20%,80%">

<frame src="Head.html" name="head">

<frameset cols="20%,80%">

<frame src="Menu.html" name="left">

<frame src="Display.html" name="right">


</frameset>

</frameset>

Insert.java:- import

java.io.*; import

java.sql.*; import

javax.servlet.*; import

javax.servlet.http.*;

public class Insert extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res)

throws IOException, ServletException { res.setContentType("text/html");

PrintWriter pw = res.getWriter();

pw.println("<form method='get'>"); pw.println("<h2>Insert Book

Details</h2>"); pw.println("Book ID: <input type='text'

name='bookid'><br>"); pw.println("Book Name: <input type='text'

name='bookname'><br>"); pw.println("Author Name: <input

type='text' name='author'><br>"); pw.println("Price: <input type='text'

name='price'><br>"); pw.println("<input type='submit'

value='Insert'>"); pw.println("</form>");

String id = req.getParameter("bookid");

String name = req.getParameter("bookname");

String author = req.getParameter("author");

String price = req.getParameter("price");

if (id != null && name != null && author != null && price != null) {

try {

Class.forName("com.mysql.cj.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");

PreparedStatement ps = con.prepareStatement("INSERT INTO book VALUES (?, ?, ?, ?)");

ps.setString(1, id); ps.setString(2, name);

ps.setString(3, author); ps.setString(4, price); int i =


ps.executeUpdate(); if (i > 0) pw.println("<h3>Book Inserted

Successfully!</h3>");

con.close();

} catch (Exception e) {

pw.println("<h3>Error: " + e + "</h3>");

Delete.java:- import

java.io.*; import

java.sql.*; import

javax.servlet.*; import

javax.servlet.http.*;

public class Delete extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse

res) throws IOException, ServletException { res.setContentType("text/html");

PrintWriter pw = res.getWriter();

pw.println("<form method='get'>"); pw.println("<h2>Delete

Book</h2>"); pw.println("Enter Book ID: <input type='text'

name='bookid'><br>"); pw.println("<input type='submit'

value='Delete'>"); pw.println("</form>");

String id = req.getParameter("bookid");

if (id != null) {

try {

Class.forName("com.mysql.cj.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");

PreparedStatement ps = con.prepareStatement("DELETE FROM book WHERE bookid=?");


ps.setString(1, id); int i = ps.executeUpdate();

if (i > 0) pw.println("<h3>Book Deleted Successfully!</h3>");

else pw.println("<h3>No Book Found with ID: " + id + "</h3>");

con.close();

} catch (Exception e) {

pw.println("<h3>Error: " + e + "</h3>");

Update.java:- import

java.io.*; import

java.sql.*; import

javax.servlet.*; import

javax.servlet.http.*;

public class Update extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {

res.setContentType("text/html");

PrintWriter pw = res.getWriter();

pw.println("<form method='get'>"); pw.println("<h2>Update

Book</h2>"); pw.println("Book ID: <input type='text'

name='bookid'><br>"); pw.println("New Price: <input

type='text' name='price'><br>"); pw.println("<input type='submit'

value='Update'>"); pw.println("</form>");

String id = req.getParameter("bookid");

String price = req.getParameter("price");

if (id != null && price != null) { try {

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");

PreparedStatement ps = con.prepareStatement("UPDATE book SET price=? WHERE bookid=?");

ps.setString(1, price); ps.setString(2, id); int i

= ps.executeUpdate(); if (i > 0) pw.println("<h3>Book Updated

Successfully!</h3>"); else pw.println("<h3>No Book Found

with ID: " + id + "</h3>");

con.close();

} catch (Exception e) {

pw.println("<h3>Error: " + e + "</h3>");

Display.java:- import

java.io.*; import

java.sql.*; import

javax.servlet.*; import

javax.servlet.http.*;

public class Display extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res)

throws IOException, ServletException { res.setContentType("text/html");

PrintWriter pw = res.getWriter();

try {

Class.forName("com.mysql.cj.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");

Statement st = con.createStatement();

ResultSet rs = st.executeQuery("SELECT * FROM book");

pw.println("<h2>Books in Database</h2>"); pw.println("<table

border='1'><tr><th>ID</th><th>Name</th><th>Author</th><th>Price</th></tr>");
while (rs.next()) { pw.println("<tr>");

pw.println("<td>" + rs.getString(1) + "</td>");

pw.println("<td>" + rs.getString(2) + "</td>");

pw.println("<td>" + rs.getString(3) + "</td>");

pw.println("<td>" + rs.getString(4) + "</td>");

pw.println("</tr>");

pw.println("</table>");

con.close();

} catch (Exception e) {

pw.println("<h3>Error: " + e + "</h3>");

web.xml:-

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="3.1">

<servlet>

<servlet-name>Insert</servlet-name>

<servlet-class>Insert</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Insert</servlet-name>

<url-pattern>/insert</url-pattern>

</servlet-mapping>

<servlet>

<servlet-name>Delete</servlet-name>

<servlet-class>Delete</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Delete</servlet-name>
<url-pattern>/delete</url-pattern>

</servlet-mapping>

<servlet>

<servlet-name>Update</servlet-name>

<servlet-class>Update</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Update</servlet-name>

<url-pattern>/update</url-pattern>

</servlet-mapping>

<servlet>

<servlet-name>Display</servlet-name>

<servlet-class>Display</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Display</servlet-name>

<url-pattern>/display</url-pattern>

</servlet-mapping>

</web-app>

OUTPUT
PRACTICLE NO : 7

Build a dynamic web application using PHP and MySQL. a. Create database tables in MySQL and create
connection with PHP b. Create the add, update, delete and retrieve functions in the PHP web app
interacting with MySQL database.

index.jsp:-

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@ page import="java.io.*" %>

<%@ page import="java.sql.*" %>

<!DOCTYPE html>

<%

Connection conn = null;

ResultSet rs = null;

Statement stmt = null;

Class.forName("com.mysql.jdbc.Driver").newInstance(); conn =

DriverManager.getConnection("jdbc:mysql://localhost:3306/ebookshop", "Kuldeep", "KP@123"); stmt =

conn.createStatement(); if (request.getParameter("action") != null) { int Stud_Id =

Integer.parseInt(request.getParameter("ID"));

String Stud_name = request.getParameter("sname");

String Stud_class = request.getParameter("sclass");

String division = request.getParameter("div");

String Stud_city = request.getParameter("city");

String query = "INSERT INTO student_info (stud_id, stud_name, class, division, city) VALUES (" +

Stud_Id + ", '" + Stud_name + "', '" + Stud_class + "', '" + division + "', '" + Stud_city + "')";

stmt.executeUpdate(query); rs = stmt.executeQuery("SELECT * FROM student_info");

%>

<html>

<head>

<title>Insert & Display Operation</title>

</head>

<body>

<center>

<h2>Student List</h2>

<table border="1" cellspacing="2" cellpadding="2">


<tr>

<th>Sr. No.</th>

<th>ID</th>

<th>Name</th>

<th>Class</th>

<th>Division</th>

<th>City</th>

</tr> <%

int num = 1;

while (rs.next()) {

%>

<tr>

<td><%= num %></td>

<td><%= rs.getInt("stud_id") %></td>

<td><%= rs.getString("stud_name") %></td>

<td><%= rs.getString("class") %></td>

<td><%= rs.getString("division") %></td>

<td><%= rs.getString("city") %></td>

</tr>

<%

num++;

rs.close();

stmt.close();

conn.close();

%>

</table>

<br>

<a href="index.jsp">Back to Registration form</a>

</center>

</body>

</html>

<% } else { %>


<html>

<head>

<title>Student Registration Form</title> <script

type="text/javascript"> function validation(Form_obj)

{ if (Form_obj.ID.value.length == 0) {

alert("Please, fill up the remaining information!");

Form_obj.ID.focus(); return false;

if (Form_obj.sname.value.length == 0) {

alert("Please, fill up the remaining information!");

Form_obj.sname.focus(); return false;

if (Form_obj.sclass.value.length == 0) {

alert("Please, fill up the remaining information!");

Form_obj.sclass.focus(); return false;

if (Form_obj.div.value.length == 0) {

alert("Please, fill up the remaining information!");

Form_obj.div.focus(); return false;

if (Form_obj.city.value.length == 0) {

alert("Please, fill up the remaining information!");

Form_obj.city.focus(); return false;

return true;

</script>

</head>

<body>

<center>

<form action="index.jsp" method="post" name="entry" onsubmit="return validation(this)">

<input type="hidden" value="list" name="action">

<table>
<tr>

<td colspan="2" align="center">

<h2>Student Entry Form</h2>

</td>

</tr>

<tr>

<td>Student ID:</td>

<td><input type="number" name="ID" size="4"></td>

</tr>

<tr>

<td>Student Name:</td>

<td><input type="text" name="sname" size="40"></td>

</tr>

<tr>

<td>Student Class:</td>

<td><input type="text" name="sclass" size="40"></td>

</tr>

<tr>

<td>Student Division:</td>

<td><input type="text" name="div" size="40"></td>

</tr>

<tr>

<td>Student City:</td>

<td><input type="text" name="city" size="40"></td>

</tr>

<tr>

<td></td>

<td><input type="submit" value="Register"></td>

</tr>

</table>

</form>

</center>

</body>
</html>

<% } %>

OUTPUT
PRACTICLE NO : 8

Design a login page with entries for name, mobile number email id and login button. Use struts and
perform following validations a. Validation for correct names b. Validation for mobile numbers c.
Validation for email id d. Validation if no entered any value e. Re-display for wrongly entered values with
message f. Congratulations and welcome page upon successful entries

connect.php:-

<?php

$connection = mysqli_connect('localhost', 'UC', '1234'); if

(!$connection){ die("Database Connection Failed" .

mysqli_error($connection)); }

$select_db = mysqli_select_db($connection, 'test'); if

(!$select_db){ die("Database Selection Failed" .

mysqli_error($connection)); }

?>

Main.php:- <?php

require('connect.php');

// delete condition if(isset($_GET['delete_id']))

$sql_query = "DELETE FROM employee WHERE name='".$_GET['delete_id']."'";

mysqli_query($connection, $sql_query); header("Location:

".$_SERVER['PHP_SELF']);

?>

<html>

<head>

<title>Simple CRUD Operations With PHP and MySql - By Coding Cage</title>

<link rel="stylesheet" href="Stylesheet1.css" type="text/css" />

<script type="text/javascript">

function edt_id(id) {

if(confirm('Sure to edit ?')) {

window.location.href='Update_data.p

hp?edit_id=' + id;
}

function delete_id(id) { if(confirm('Sure to Delete

?')) {

window.location.href='Main.php?delete_id=' + id;

</script>

</head>

<body>

<table bgcolor="Pink" border="2" width="60%" align="center" valign="middle">

<tr align="center"><td valign="bottom"><h1>CRUD Operations on Employee Database</h1></td></tr>

<tr><td colspan="3"><marquee><a href="CreateData.html">Create Data</a></marquee></td></tr>

</table>

<table bgcolor="SkyBlue" border="2" width="60%" align="center" cellpadding="15px"> <tr>

<th>Name</th>

<th>Age</th>

<th>City Name</th>

<th>Salary</th>

<th colspan="2">Operations</th>

</tr>

<?php

$sql_query = "SELECT * FROM employee";

$result_set = mysqli_query($connection, $sql_query);

if(mysqli_num_rows($result_set) > 0) {

while($row = mysqli_fetch_row($result_set)) {

?>

<tr>

<td><?php echo $row[0]; ?></td>

<td><?php echo $row[1]; ?></td>

<td><?php echo $row[2]; ?></td>

<td><?php echo $row[3]; ?></td>


<td align="center"><a href="javascript:edt_id('<?php echo $row[0]; ?>')"><img src="b_edit.png" alt="EDIT"
/></a></td>

<td align="center"><a href="javascript:delete_id('<?php echo $row[0]; ?>')"><img src="b_drop.png" alt="DELETE"


/></a></td>

</tr>

<?php

} else {

?>

<tr>

<td colspan="5">No Data Found !</td>

</tr>

<?php

?>

</table>

</body>

</html>

CreateData.html:-

<html>

<head>

<title>Create Employee</title>

<link rel="stylesheet" href="Stylesheet1.css" type="text/css" />

</head>

<body>

<form action="insert.php" method="post">

<table bgcolor="Pink" border="2" width="60%" align="center" valign="middle">

<tr align="center"><td valign="bottom"><h1>Create Data Form</h1></td></tr>

</table>

<table bgcolor="SkyBlue" border="2" width="60%" align="center" cellpadding="15px">

<tr><td>Employee Name:</td><td><input type="text" name="name" /></td></tr>

<tr><td>Employee Age:</td><td><input type="text" maxlength="3" name="age"/></td></tr>

<tr><td>Select Gender:</td>

<td><select name="sex"><option>Male</option><option>Female</option></select></td>

</tr>
<tr><td>Employee Salary:</td><td><input type="text" maxlength="6" name="sal"/></td></tr>

<tr align="center"><td><input type="submit" value="Register" class="ab"></td>

<td><input type="Reset" value="Reset" class="ab"></td></tr>

</table>

</form>

</body>

</html>

insert.php:- <?php require('connect.php'); if (isset($_POST['name']) && isset($_POST['age']) &&

isset($_POST['sex']) && isset($_POST['sal'])) {

$ename = $_POST['name'];

$age = $_POST['age'];

$sex = $_POST['sex'];

$salary = $_POST['sal'];

$query = "INSERT INTO employee(name, age, sex, salary) VALUES('$ename', $age, '$sex', $salary)";

$retvalue = mysqli_query($connection, $query);

if(!$retvalue) { echo "<script>alert('Error occurred while inserting

your data');</script>";

} else { echo "<script>alert('Data Inserted Successfully');

window.location.href='index.php';</script>";

?>

Update_data.php:-

<html>

<head>

<title>Update Employee</title>

<link rel="stylesheet" href="Stylesheet1.css" type="text/css" />

</head>

<body>

<form action="Update_data.php" method="post">

<table bgcolor="Pink" border="2" width="60%" align="center" valign="middle">

<tr align="center"><td><h1>Update Data Form</h1></td></tr>


</table>

<table bgcolor="SkyBlue" border="2" width="60%" align="center" cellpadding="15px">

<tr><td>Employee Name:</td><td><input type="text" name="name" value="" /></td></tr>

<tr><td>Employee Age:</td><td><input type="text" maxlength="3" name="age"/></td></tr>

<tr><td>Select Gender:</td>

<td><select name="sex"><option>Male</option><option>Female</option></select></td>

</tr>

<tr><td>Employee Salary:</td><td><input type="text" maxlength="6" name="sal"/></td></tr>

<tr align="center">

<td><input type="submit" value="Update" name="update" class="ab"></td>

<td><input type="submit" value="Cancel" name="cancel" class="ab"></td>

</tr>

</table>

</form>

</body>

</html>

<?php

require('connect.php'); if

(isset($_GET['edit_id'])) {

$sql_query = "SELECT * FROM employee WHERE name='".$_GET['edit_id']."'";

$result_set = mysqli_query($connection, $sql_query);

$fetched_row = mysqli_fetch_array($result_set);

if (isset($_POST['update'])) {

$ename = $_POST['name'];

$age = $_POST['age'];

$sex = $_POST['sex'];

$salary = $_POST['sal'];

$sql_query = "UPDATE employee SET name='$ename', age=$age, sex='$sex', salary=$salary WHERE

name='".$_GET['edit_id']."'"; if (mysqli_query($connection, $sql_query)) { echo

"<script>alert('Data Are Updated Successfully'); window.location.href='Main.php';</script>";

} else { echo "<script>alert('Error occurred while updating

data');</script>";
}

if (isset($_POST['cancel'])) {

header("Location: Main.php");

?>

Stylesheet1.css:- h1 {

font-family: Poor Richard;

font-size: 300%;

h2 { font-family: Poor

Richard; font-size: 200%;

td { font-family: Bodoni

MT; font-size: 100%;

input { font-family:

Bodoni MT; font-size:

100%; margin: 5px 0;

.ab { background-color:

Gray;

color: white;

padding: 14px 20px;

margin: 8px 0;

border: none; cursor:

pointer; width: 50%;

opacity: 0.9;

}
select { font-family:

Bodoni MT; font-size:

100%; margin: 5px 0;

OUTPUT
PRACTICLE NO : 9

Design an application using Angular JS. e.g., Design registration (first name, last name, username, and
password) and login page using Angular JS.

Login.jsp:-

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@ taglib uri="/struts-tags" prefix="a" %>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Login Page</title>

</head>

<body>

<center>

<h2>WEB TECHNOLOGY LAB (T. E. Comp. 2019 Course)</h2>

<h3>Navsahydri pune</h3>

<a:form action="Login" validate="true">

<a:textfield label="Enter UserName" name="UN"/>

<a:textfield label="Enter MobileNumber" name="MN"/>

<a:textfield label="Enter Email ID" name="email"/>

<a:submit value="Login"/>

</a:form>

</center>

</body>

</html>

Welcome.jsp:-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO8859-1"%>

<%@ taglib uri="/struts-tags" prefix="a" %>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Welcome</title>
</head>

<body>

<center>

<h1>Congratulations!!!</h1>

<h2>Welcome User <a:property value="UN"/></h2>

</center>

</body>

</html>

LoginProg.java:- package

org.struts;

import com.opensymphony.xwork2.ActionSupport;

import java.util.regex.Matcher; import

java.util.regex.Pattern; public class LoginProg

extends ActionSupport { private String UN;

private String MN; private String email;

public String execute() { return SUCCESS;

public String getUN() {

return UN;

public void setUN(String UN) {

this.UN = UN;

public String getMN() {

return MN;

public void setMN(String MN) {

this.MN = MN;
} public String

getEmail() { return

email;

public void setEmail(String email) {

this.email = email;

} public void validate() { // Validate User Name if

(getUN().length() == 0) addFieldError("UN", "User Name is

required!"); else if (!getUN().equals("Admin"))

addFieldError("UN", getUN() + " is not an authentic user name.");

// Validate Mobile Number if (getMN().length() != 10)

addFieldError("MN", "Mobile Number must be 10 digits!");

else if (!getMN().equals("1234567890"))

addFieldError("MN", getMN() + " is not an authentic mobile number!")

// Validate Email if (getEmail().length() == 0)

addFieldError("email", "Email-ID is required!"); else if

(!getEmail().equals("[email protected]"))

addFieldError("email", email + " is not an authentic email-id.");

else {

String expression = "^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";

Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);

Matcher matcher = pattern.matcher(email); if (!matcher.matches())

addFieldError("email", "Invalid email address!");

struts.xml:-

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

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.custom.i18n.resources" value="LoginProg"/

<package name="default" extends="struts-default" namespace="/">

<action name="Login" class="org.struts.LoginProg" method="execute">

<result name="success">/Welcome.jsp</result>

<result name="input">/Login.jsp</result>

</action>

</package>

</struts>

OUTPUT
PRACTICLE NO : 10

Design and implement a business interface with necessary business logic for any web application using
EJB. e.g., Design and implement the web application logic for deposit and withdraw amount transactions
using EJB.

Login.jsp —

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@

taglib uri="/struts-tags" prefix="a" %>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Login Page</title>

</head>

<body>

<center>

<h2>WEB TECHNOLOGY LAB (T. E. Comp. 2019 Course)</h2>

<h3>Trinity Academy of Engineering, Pune</h3>

<a:form action="Login" validate="true">

<a:textfield label="Enter UserName" name="UN"/>

<a:textfield label="Enter MobileNumber" name="MN"/>

<a:textfield label="Enter Email ID" name="email"/>

<a:submit value="Login"/>

</a:form>

</center>

</body>

</html>

Welcome.jsp:-

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@

taglib uri="/struts-tags" prefix="a" %>

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">
<title>Welcome</title>

</head>

<body>

<center>

<h1>Congratulations!!!</h1>

<h2>Welcome User <a:property value="UN"/></h2>

</center>

</body>

</html>

LoginProg.java:- package

org.struts;

import com.opensymphony.xwork2.ActionSupport;

import java.util.regex.Matcher; import

java.util.regex.Pattern;

public class LoginProg extends ActionSupport {

private String UN; private String MN; private

String email;

// Executes after successful validation

public String execute() { return

SUCCESS;

// Getters and Setters public String getUN() {

return UN; } public void setUN(String UN) {

this.UN = UN; }

public String getMN() { return MN; } public void

setMN(String MN) { this.MN = MN; }

public String getEmail() { return email; } public void

setEmail(String email) { this.email = email; }


// Custom validation logic

public void validate() { //

Validate User Name if

(getUN().length() == 0)

addFieldError("UN", "User

Name is required!"); else

if

(!getUN().equals("Admin"))

addFieldError("UN",

getUN() + " is not an

authentic user name.");

// Validate Mobile Number if (getMN().length() != 10)

addFieldError("MN", "Mobile Number must be 10 digits!"); else if

(!getMN().equals("1234567890")) addFieldError("MN", getMN() + " is

not an authentic mobile number!");

// Validate Email if (getEmail().length() == 0)

addFieldError("email", "Email-ID is required!"); else if

(!getEmail().equals("[email protected]"))

addFieldError("email", email + " is not an authentic email-id.");

else {

String expression = "^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";

Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);

Matcher matcher = pattern.matcher(email); if (!matcher.matches())

addFieldError("email", "Invalid email address!");

struts.xml:-

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

<!DOCTYPE struts PUBLIC

"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<!-- Resource Bundle -->

<constant name="struts.custom.i18n.resources" value="LoginProg"/>

<package name="default" extends="struts-default" namespace="/">

<!-- Mapping Login action to LoginProg.java -->

<action name="Login" class="org.struts.LoginProg" method="execute">

<result name="success">/Welcome.jsp</result>

<result name="input">/Login.jsp</result>

</action>

</package>

</struts>

OUTPUT

You might also like