Web Technology lab FILE
Course Name: Web Technology Lab
Course Code: E1UJ401C
B.Sc. Computer Science
2ND Year, Semester- 4th
AcademicYear:2022-2023
School of Computing Science and
Engineering
Submitted by: Submitted to:
Lakshy Awasthi P. Rajakumar
21SCSE1100020 Assistant Professor SCSE
Sector 17A Yamuna Expressway, Greater Noida
Gautam Buddha Nagar, Uttar Pradesh 201303
Index
Sr. Date Experiment Signatur
No. e
1 11/02/23 Create a web page with the following using html.
a) To imbed an image map in a web page.
b) To fix the hot spots.
c) Show all the related information when hotspots are clicked
2 18/02/23 Create a web page with all types of Cascading style sheets.
3 25/02/23 Write a PHP script to merge two arrays and sort them as numbers, in
descending order
4 4/03/23 Develop a car showroom inventory web application with 2-tier
architecture. Use JSP and JDBC
5 25/03/23 a) Write a Servlet program to generate plain text.
b) Write a servlet program to display cookie id.
6 1/04/23 To create a simple XML document to display the address book.
7 1/04/23 Internal and External DTD creation.
8 8/04/23 Write a Java script to prompt for user name and display it on the
screen.
9 15/04/23 Write a JavaScript program to convert temperatures to and from
Celsius, Fahrenheit
10 22/04/23 Write a java script for loop that will iterate from 0 to 20 for each
iteration, it will check if the current number is odd or even and
display a message to the screen.
Experiment 01- Create a web page with the following using html.
i. To imbed an image map in a web page.
ii. To fix the hot spots.
iii. Show all the related information when hotspots are clicked.
Code -
Result-
Experiment 02- Create a webpage with all types of Cascading Style Sheets.
Code-
CSS file-
Result-
Experiment 03- Write a PHP script to merge two arrays and sort them as numbers, in
descending order.
Code-
Result-
Experiment 04- Write a Java script to prompt for users name and display it on the screen.
Code-
Result-
Phase 1-
Phase 2-
Phase 3-
Experiment 05- Write a JavaScript program to convert temperatures to and from Celsius and
Fahrenheit.
Code-
Result-
Experiment 06- Write a java script for loop that will iterate from 0 to 20 for each iteration, it
will check if the current number is odd or even, and display a message to the screen.
Code-
Result-
Experiment 07- To create a simple XML document to display the address book.
Procedure:
Step-1: Create the xml document using notepad.
Step-2: Create the address book as a root tag.
Step-3: Followed by create three employees address in detail using different tag.
Step-4: Save the file as “Employee.xml”.
Step-5: Finally execute the program in Internet Explorer to view the output.
Source Code:
Filename: “Employee.xml”
<?xml version = "1.0" encoding="UTF-8" standalone="yes" ?>
<addressbook>
<emp1>
<name>Karthick</name>
<doorno>No-2/57</doorno>
<street>Vinayakam St</street>
<area>Teynampet</area>
<city>Chennai-600020</city>
<state>Tamil Nadu</state>
<country>India</country>
<phoneno>909583625</phoneno>
</emp1>
<emp2>
<name>Murali</name>
<doorno>No-25/7</doorno>
<street>ParthasarathyKoil Street</street>
<area>Triplecane</area>
<city>Chennai-600005</city>
<state>Tamil Nadu</state>
<country>India</country>
<phoneno>9962589632</phoneno>
</emp2>
<emp3>
<name>Jagagish</name>
<doorno>No-25</doorno>
<street>Palani Street,</street>
<area>Manali</area>
<city>Chennai-600055</city>
<state>Tamil Nadu</state>
<country>India</country>
<phoneno>9003862541</phoneno>
</emp3>
</addressbook>
Output-
Experiment 08- Internal and external DTD creation.
Source Code for Internal DTD creation:
File name:“Sche.xml”
<?xml version="1.0" ?>
<!DOCTYPE books [
<!ELEMENT books (book)*>
<!ELEMENT book (title?,isbn+,(zipcode|author),publish*)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT zipcode (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publish (#PCDATA)>
<!ATTLIST zipcode zname CDATA "232232323">
<!ATTLIST publish year CDATA #FIXED "1995">
<!ATTLIST title name CDATA #IMPLIED>
<!ATTLIST isbn number CDATA #REQUIRED>
]>
<books>
<book>
<title name="C"></title>
<isbn number="2309"></isbn>
<zipcode zname="23244345345"></zipcode>
<publish year="1998"></publish>
</book>
<book>
<title name="C++"></title>
<isbn number="2310"></isbn>
<zipcode zname="45814845585"></zipcode>
<publish year="1995"></publish>
</book>
<book>
<title name="JAVA"></title>
<isbn number="2311"></isbn>
<zipcode zname="553378845585"></zipcode>
<publish year="1995"></publish>
</book>
<book>
<book>
<title name="PUZZLES"></title>
<isbn number="2313"></isbn>
<zipcode zname="456644445"></zipcode>
<publish year="1995"></publish>
</book>
<book>
<title name="XML"></title>
<isbn number="2312"></isbn>
<zipcode zname="412684895585"></zipcode>
<publish year="1995"></publish>
</book>
</books>
Filename:“Par.html”
<html>
<body>
<h3>This demonstrates a parser error:</h3>
<script type="text/javascript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.validateOnParse="true";
xmlDoc.load("Sche.xml");
document.write("<br/>Error Code:");
document.write(xmlDoc.parseError.errorCode);
document.write("<br/>Error Reason:");
document.write(xmlDoc.parseError.reason);
document.write("<br/>Error Line:");
document.write(xmlDoc.parseError.line);
</script>
</body>
</html>
Output-
Source Code for External DTD creation:
Filename:“not.dtd”
<!ELEMENT books (book)*>
<!ELEMENT book (title?,isbn+,(zipcode|author),publish*)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT zipcode (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publish (#PCDATA)>
<!ATTLIST zipcode zname CDATA "232232323">
<!ATTLIST publish year CDATA #FIXED "1995">
<!ATTLIST title name CDATA #IMPLIED>
<!ATTLIST isbn number CDATA #REQUIRED>
Filename: “Sc.xml”
<?xml version="1.0" ?>
<!DOCTYPE books SYSTEM "not.dtd">
<books>
<book>
<title name="C"></title>
<isbn number="2309"></isbn>
<zipcode zname="23244345345"></zipcode>
<publish year="1995"></publish>
</book>
<book>
<title name="C++"></title>
<isbn number="2310"></isbn>
<zipcode zname="23244345345"></zipcode>
<publish year="1995"></publish>
</book>
</books>
Filename:“Pars.html”
<html>
<body>
<h3>This demonstrates a parser error:</h3>
<script type="text/javascript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.validateOnParse="true";
xmlDoc.load("Sc.xml");
document.write("<br/>Error Code:");
document.write(xmlDoc.parseError.errorCode);
document.write("<br/>Error Reason:");
document.write(xmlDoc.parseError.reason);
document.write("<br/>Error Line:");
document.write(xmlDoc.parseError.line);
</script>
</body>
</html>
Output-
Experiment 09- Write a servlet program to generate plain text.
Session1.html
<html>
<head><title> SESSION LOGIN </title></head>
<body>
<center>
<form action="http://localhost:8080/Session1/session6vib" method="get">
Enter Name: <input type="text" name="uname"><br>
<input type="submit" value="LOGIN" name="register">
</form>
</center>
</body>
</html>
Session1.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Session1 extends HttpServlet
{
public void doGet(HttpServletRequestreq, HttpServletResponse res) throwsIOException,
ServletException
{
try
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<form method=get action=session26vib>");
Date d=new Date();
out.println("<p align=right> Time:"+d.getTime()+"</p>");
String un=req.getParameter("uname");
HttpSession session=req.getSession();
session.setAttribute("user",un);
session.setAttribute("time",d.getTime());
out.println("Hello\t"+un);
out.println("<br><br><input type=submit value=logout>");
out.println("</form");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
web.xml
<?xml version="1.0"?>
<web-app>
<servlet>
<servlet-name>session1</servlet-name>
<servlet-class>Session1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>session1</servlet-name>
<url-pattern>/session6vib</url-pattern>
</servlet-mapping>
</web-app>
OUTPUT:
Experiment 10- Write a servlet program to display cookie id.
Code-
index.html
<form action="servlet1" method="post">
Name:<input type="text" name="userName"/><br/>
<input type="submit" value="go"/>
</form>
FirstServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class FirstServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response){
try{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String n=request.getParameter("userName");
out.print("Welcome "+n);
Cookie ck=new Cookie("uname",n);//creating cookie object
response.addCookie(ck);//adding cookie in the response
//creating submit button
out.print("<form action='servlet2'>");
out.print("<input type='submit' value='go'>");
out.print("</form>");
out.close();
}catch(Exception e){System.out.println(e);
}
}
}
SecondServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SecondServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response){
try{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Cookie ck[]=request.getCookies();
out.print("Hello "+ck[0].getValue());
out.close();
}catch(Exception e){System.out.println(e);}
}
}
web.xml
<web-app>
<servlet>
<servlet-name>s1</servlet-name>
<servlet-class>FirstServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>s1</servlet-name>
<url-pattern>/servlet1</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>s2</servlet-name>
<servlet-class>SecondServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>s2</servlet-name>
<url-pattern>/servlet2</url-pattern>
</servlet-mapping>
</web-app>
Output-