Web Technology
Web Technology
(Approved by AICTE & Affiliated to Dr. APJ Abdul Kalam Technical University (Formerly UPTU), Lucknow)
Department of Computer Science and Engineering
Session 2022-23 EVEN semester
Aim: HTML/Java Scripts Code To Display Your CV In Navigator, Your Institute Website,
Department Details.
Code:
<!DOCTYPE html>
<html>
<head>
<title>My CV</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
}
h1, h2, h3 {
margin-top: 0;
}
h2 {
font-size: 24px;
}
h3 {
font-size: 20px;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
section {
margin: 20px;
}
section h2 {
font-size: 24px;
margin-bottom: 10px;
}
section p {
line-height: 1.5;
section ul li {
margin-bottom: 10px;
}
a{
color: #333;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<header>
<h1>Mr. XYZ</h1>
<p>Web Developer</p>
</header>
<section>
<h2>Summary</h2>
<p>A web developer with experience in HTML, CSS, and JavaScript.</p>
</section>
<section>
<section>
<h2>Skills</h2>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>jQuery</li>
<li>WordPress</li>
<li>Drupal</li>
</ul>
</section>
<section>
<h2>About the Department</h2>
<p>The Department of Computer Science at the Krishna Engineering College offers
undergraduate and graduate programs in computer science.</p>
</section>
<section>
<h2>Faculty</h2>
<ul>
<li>Mr. Kavindra Garg</li>
<li>Mr. Prashant Naresh</li>
<li>Mr. Rahul Rastogi</li>
<li>Mr. Deepak Sethi</li>
</ul>
</section>
<section>
<h2>Courses</h2>
<ul>
<li>Introduction to Computer Science</li>
<li>Data Structures and Algorithms</li>
<li>Operating Systems</li>
<li>Database Systems</li>
<li>Software Engineering</li>
</ul>
</section>
<section>
<h2>Research Areas</h2>
<ul>
<li>Artificial Intelligence</li>
<li>Computer Networks</li>
<li>Distributed Systems</li>
<li>Human-Computer Interaction</li>
<section>
<h2>Contact Information</h2>
<p>Department of Computer Science<br>
Krishna Engineering College<br>
Mohan Nagar,GZB<br>
India<br>
Phone: 9999110872<br>
<a href="https://www.krishnacollege.ac.in/">College Details</a>
</section>
</body>
</html>
Practical no:-2 Name of the practical:-To Design An Entry Form Of Student Details
Student Roll no:- Student Name:- Semester/Batch:-6
Aim: Html Program To Design An Entry Form Of Student Details And Send It store At
Database Server Like SQL, Oracle Or MS Access.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Student Entry Form</title>
</head>
<body>
<h1>Student Entry Form</h1>
<form action="submit.php" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br>
<label for="phone">Phone:</label>
<input type="tel" id="phone" name="phone" required><br>
<label for="gender">Gender:</label>
<label for="address">Address:</label>
<textarea id="address" name="address" required></textarea><br>
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if (mysqli_query($conn, $sql)) {
echo "Record added successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
Aim: Programs Using Java Script For Web Page To Display To Browsers Information.
Code:
<html>
<body>
<script type="text/javascript">
document.write("Browser Name: "+ navigator.appName);
document.write("Browser Version: "+ navigator.appVersion);
document.write("Cookies Enabled: "+ navigator.cookieEnabled);
document.write("Platform: "+navigator.platform);
document.write("User-agent header: " +navigator.userAgent);
</script></body>
</html>
Practical no:-4 Name of the practical:-To Display The Application Program Screen
Student Roll no:- Student Name:- Semester/Batch:-6
Aim: Write A Java Applet To Display The Application Program Screen i.e. Calculator.
Code:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
Aim: Write A XML For Creating DTD, Which Specifies Set Of Rules. Create a CSS/XSL
& Display The Document In A Browser.
Code:
XML Document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book [
<!ELEMENT book (title, author, publisher, year, price)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ATTLIST book id CDATA #IMPLIED>
]>
<book id="bk001">
<title>The Catcher in the Rye</title>
<author>J.D. Salinger</author>
<publisher>Little, Brown and Company</publisher>
<year>1951</year>
<price>19.99</price>
</book>
CSS Code:
title {
font-size: 24px;
<xsl:template match="book">
<div>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="author"/>
<xsl:apply-templates select="publisher"/>
<xsl:apply-templates select="year"/>
<xsl:apply-templates select="price"/>
</div>
</xsl:template>
<xsl:template match="title">
<h2>
<xsl:value-of select="."/>
</h2>
</xsl:template>
<xsl:template match="author">
<p>
<xsl:template match="publisher">
<p>
Published by <xsl:value-of select="."/>
</p>
</xsl:template>
<xsl:template match="year">
<p>
Published in <xsl:value-of select="."/>
</p>
</xsl:template>
<xsl:template match="price">
<p>
Price: $<xsl:value-of select="."/>
</p>
</xsl:template>
</xsl:stylesheet>
Aim: Design And Implement A Simple Servlet Book Query With The Help Of JDBC &
SQL.
Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
try {
Class.forName("com.mysql.jdbc.Driver");
out.println("<html>");
out.println("<head>");
out.println("<title>Book Query Results</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Book Query Results</h1>");
out.println("<table>");
out.println("<tr><th>ID</th><th>Title</th><th>Author</th><th>Price</th></tr>");
while (rs.next()) {
int id = rs.getInt("id");
String title = rs.getString("title");
String author = rs.getString("author");
double price = rs.getDouble("price");
out.println("<tr><td>" + id + "</td><td>" + title + "</td><td>" + author + "</td><td>"
+ price + "</td></tr>");
}
out.println("</table>");
out.println("</body>");
out.println("</html>");
Practical no:-8 Name of the practical:-Develop A Static Web Page Using JSP
Student Roll no:- Student Name:- Semester/Batch:-6
Aim: Install Tomcat Web Server And Develop A Static Web Page Using JSP For Book
Web Site.
Code:
Installing Tomcat Web Server:
1. Download the latest version of Tomcat from the official Apache Tomcat website.
2. Extract the downloaded file into a folder of your choice.
3. Set the JAVA_HOME environment variable to the path of your Java installation.
4. Open a command prompt and navigate to the bin folder inside the Tomcat directory.
5. Run the startup.bat file to start the Tomcat server.
6. Open a web browser and navigate to http://localhost:8080/ to confirm that Tomcat is
running.
7. To stop the server, run the shutdown.bat file in the bin folder.
You can now deploy your web applications to Tomcat by placing them in the webapps
folder inside the Tomcat directory.
JSP Code:
<!DOCTYPE html>
<html>
<head>
<title>My Book Site</title>
</head>
<body>
<header>
<h1>Welcome to My Book Site</h1>
</header>
<section>
<h2>Featured Books</h2>
<ul>
<li>
<a href="#">Book Title 1</a>
<p>Author: John Smith</p>
<p>Price: $9.99</p>
</li>
<li>
<a href="#">Book Title 2</a>
<p>Author: Jane Doe</p>
<p>Price: $12.99</p>
</li>
<li>
<a href="#">Book Title 3</a>
<p>Author: Bob Johnson</p>
<p>Price: $7.99</p>
</li>
</ul>
</section>
<section>
<h2>Top Categories</h2>
<ul>
<li><a href="#">Fiction</a></li>
<li><a href="#">Non-fiction</a></li>
<li><a href="#">Mystery</a></li>
<li><a href="#">Thriller</a></li>
<section>
<h2>About Us</h2>
<p>We are a book website that offers a wide selection of books in various
categories. Our goal is to provide a user-friendly experience for our customers and to
make it easy for them to find the books they want.</p>
</section>
<footer>
<p>© 2023 My Book Site</p>
</footer>
</body>
</html>
Semester/Batch:-6
Aim: Assume Four Users User1, User2, User3 And User4 Having Password Pwd1,
Pwd2, Pwd3 And Pwd4 Respectively.
a. Create a Cookie and add these four user id’s and passwords to this Cookie.
b. Read the user id and passwords entered in the Login form and authenticate with the
values available in the cookies.
Code:
A. Cookie Creation:
import javax.servlet.http.Cookie;
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;
response.addCookie(user1Cookie);
<%
String userId = request.getParameter("userId");
String password = request.getParameter("password");
Cookie[] cookies = request.getCookies();
boolean authenticated = false;
if (cookies != null) {
for (Cookie cookie : cookies) {
String name = cookie.getName();
String value = cookie.getValue();
Practical no:-10 Name of the practical:-Write A JSP Which Insert The Details Of 3-4 User
Student Roll no:- Student Name:- Semester/Batch:-6
Aim: Write A JSP Which Insert The Details Of 3-4 Users Who Register With The
Website By Using Registration Form. Authenticate The User When He Submits The
Login Form Using The Username And Password From The Database.
Code:
<%@ page import="java.sql.*" %>
<%
String url = "jdbc:mysql://localhost:3306/mydatabase"; // replace with your MySQL
database name
String user = "root"; // replace with your MySQL username
String password = "password"; // replace with your MySQL password
if (username != null && password != null && fullname != null && email != null) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
String sql = "INSERT INTO users (username, password, fullname, email) VALUES
('" + username + "', '" + password + "', '" + fullname + "', '" + email + "')";
stmt.executeUpdate(sql);
stmt.close();