0% found this document useful (0 votes)
21 views50 pages

Webtechnologylabmanualpdf 240131072014 3b5b7428

web technologies record

Uploaded by

jayapriyamani03
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)
21 views50 pages

Webtechnologylabmanualpdf 240131072014 3b5b7428

web technologies record

Uploaded by

jayapriyamani03
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/ 50

DEPARTMENT OF INFORMATION TECHNOLOGY

LABORATORY MANUAL

22IT401-WEB TECHNOLOGY LABORATORY


Regulation 2022
Year/Semester : II/IV
2023 – 2024 (Even Semester)

PREPARED BY
Mrs. K. M. Preethi
Teaching Assistant
1
22IT401 - WEB TECHNOLOGY

Course Objectives:
1. To understand different Internet Technologies

2. To learn java-specific web services architecture

3. To Develop web applications using frameworks

List of Experiments:
1.Create a web page with the following using HTML.

 To embed an image map in a web page.


 To fix the hot spots.
 Show all the related information when the hot spots are clicked

2. Create a web page with all types of Cascading style sheets.

3. Client Side Scripts for Validating Web Form Controls using DHTML.

4. Installation of Apache Tomcatweb server.

5. Write programs in Java using Servlets:

 To invoke servlets from HTML forms.


 Session Tracking

6. Write programs in Java to create three-tier applications using JSP and


Databases

 For conducting on-line examination.


 For displaying student mark list. Assume that student information is
available in a database which has been stored in a database server

7. Programs using XML – Schema – XSLT/XSL

2
TABLE OF CONTENTS

S.NO. DATE EXPERIMENT TITLE MARKS SIGN


(50)
1. Create a web page with the
following using HTML.
 To embed an image map
in a web page.
 To fix the hot spots.
 Show all the related
information when the hot
spots are clicked

2. Create a web page with all types


of Cascading style sheets.

3. Client Side Scripts for Validating


Web Form Controls using
DHTML.

4. Installation of Apache
Tomcatweb server.

5. Write programs in Java using


Servlets:
 To invoke servlets from
HTML forms.
 Session Tracking

6. Write programs in Java to create


three-tier applications using JSP
and Databases
 For conducting on-line
examination.
 For displaying student
mark list. Assume that
student information is
available in a database
which has been stored in
a database server

7. Programs using XML – Schema


– XSLT/XSL

3
Ex. No. : 1 CREATION OF IMAGE MAP TO FIX
HOTSPOTS
Date:

AIM

To create a webpage with image map to fix the hotspots and show its related
information.

SOFTWARE USED

Dreamweaver or Notepad and browser.

DESCRIPTION

In Web page development, an image map is a graphic image defined so that a


user can click on different areas of the image and be linked to different
destinations. You make an image map by defining each of the sensitive areas in
terms of their x and y coordinates (thatis, a certain horizontal distance and a
certain vertical distance from the left-hand corner of the image). With each set
of coordinates, you specify a Uniform Resource Locator or Web address that
will be linked to when the user clicks on that area.

There are three HTML elements used to create image maps:

<img>specifies the location of the image to be included in the map.

<map>is used to create the map of clickable areas.

<area>is used with in the map element to define the clickable areas.

CODE
4
main.html

<html>

<head>

<BODYbgcolor="#gop6876cgdt5564ss">

<imgsrc="indiamap.jpeg"usemap="#indiamap" />

<mapname=indiamap>

<areashape="circle"coords="500,1092,15"href="tamilnadu.html"alt="Tamilnadu
">

<areashape="rect"coords="376,1076,406,1100"href="karnataka.html"alt="Karna
taka">

</map>

</head>

</BODY>

</html>

tamilnadu.html

<html>

<head><title>TanilNadu -India</title></head>

<bodybgcolor="palegreen">

<h1><center>TamilNadu</center></h1>

<h3>isoneofthe29states of India. Its capital and largest city is Chennai.


TamilNadu lies in the southern most part of the Indian Peninsula and is bordered
by the States of puducherry,Kerala,Karnataka,AndhaPradesh.</h3>

<h3>

<ul>

5
<li>Districts<i>-33</i>

<li>CapitalCity<i>-Chennai</i>

<li>LargestCity<i>-Chennai</i>

<li>Governor<i>-BanwarilalPurohit</i>

<li>ChiefMinister<i>-EdappadiK.Palaniswami</i>

<li>Population<i>-72,147,030</

<li>Tourist spots<i> - Mamallapuran, Ooty, Kodaikanal, Marina,Mudurai


Meenakshi Amman Temple,Thanjavuretc.,</i>

</ul>

<ahref="main.html">back</a>

</body>

</html>

karnataka.html

<html>

<head><title>Karnataka-India</title></head>

<bodybgcolor="wheat">

<h1><center>Karnataka</center></h1>

<h3>

<ul>

<li>Districts<i>-30</i>

<li>CapitalCity<i>-Bangalore</i>

<li>LargestCity<i>-Bangalore</i>

<li>Governor<i>-VajubhaiVala</i>

<li>ChiefMinister<i> -H. D. Kumaraswamy</i>

6
<li>Population<i>-61,130,704</i>

<li>Touristspots<i>-GolGumbaz,MysorePalace,KeshavaTempleetc.,</i>

</ul>

</h3>

<ahref="main.html">back</a>

</body>

</html>

OUTPUT

7
RESULT

Thus the Web Page had been created using image map to fix the hotspots and
relevant information had been displayed.

8
Ex. No. : 2 CREATION OF WEB PAGE WITH ALL TYPES OF
Date: CASCADING STYLESHEETS

AIM

To create a webpage with all types of Cascading Style Sheets.

SOFTWARE USED

Dreamweaver or Notepad and browser

DESCRIPTION

Cascading Style Sheet (CSS) is used to set the style in web pages which contain
HTML elements. It sets the background color, font-size, font-family, color etc
property of elements in a web pages.

There are three types of CSS which are given below:

Inline CSS
Internal or Embedded CSS
External CSS

ALGORITHM

Internal CSS:

STEP1: Create a HTML program with <style> tag.

STEP 2: Inside the <style> tag, specify the format required for that web page

STEP3: Run the program with a web browser.

External CSS:

9
STEP 4: Open a notepad, type the needed CSS in it and save it with .css
extension. STEP5:Refer this .css file in the HTML using the tag<link>.

STEP6:Run the program with a webbrowser.

CODE

style.html

<html>

<head>

<title>FLOWERS</title>

<!--ExtendedStyleSheet-->

<linkrel="stylesheet"type="text/css"href="style.css">

<!--EmbedStyleSheet-->

<style type="text/css">p{

background-color:

lightgrey;text-align:justify; margin:2em7em;

</style>

</head>

<bodyid="body">

<h1>FLOWER</h1>

<p>

<span style="font: 200 x-large fantasy">Flower</span>sometimesknown as


abloom or blossom,

Is there productive structure found in flowering plants.

he flower is God's finest workmanship in the world.It is his finest gift to the
mankind.

10
We have seent he flowers of many kinds and to many colors.In India we see the
flowers like

</p>

<!--InlineSytleSheet-->

<tablestyle="background-position:center;text-align:center;padding:3px;">

<tr>

<tdalign="left">

<divclass="div">

<ul>

<li><ahref="">Lily</a></li>

<li><ahref="">Lotus</a></li>

<li><ahref="">Rose</a></li>

<li><ahref="">Jasmine</a></li>

</ul>

</div>

</td>

</tr>

</table>

</body>

</html>

style.css

h1,h2{

text-decoration: underline;font-style:italic;

text-align:center;

11
}

#body{ background-color: tan;border: red dotted;text- align:center;

.div{ border:perusolid;

*{

letter-spacing:1px;

a:link{color

:black;

a:visited{colo r:yellow;

a:hover{color

:green;

a:active{col or:blue;

ul li{

font-size:small;

12
OUTPUT

RESULT

Thus a webpage has been created with all types of CSS.


13
Ex. No. : 3 CLIENT SIDE SCRIPTS FOR VALIDATING WEB
Date: FORM CONTROLSUSINGDHTML

AIM

To create a DHTML for validating web form controls.

SOFTAREUSED

Dreamweaver or Notepad and browser.

DESCRIPTION

DHTML stands for Dynamic HTML, it is totally different from HTML. The
browsers which support the dynamic HTML are some of the versions of
Netscape Navigator and Internet Explorer of version higher than 4.0. The
DHTML is based on the properties of the HTML, javascript, CSS, and DOM
(Document Object Model which is used to access individual elements of a
document) which helps in making dynamic content. It is the combination of
HTML, CSS, JS, and DOM. The DHTML make use of Dynamic
objectmodel to take changes in settings and also in properties and methods. It
also makes uses of Scripting and it is also part of earlier computing trends.

ALGORITHM

The form will include one text field called "Your Name ",and a submit button.

Validation script will ensure that the user enters their name before the form is
sent to the server.

Open this page to see it in action.

Try pressing the Send Details button with out filling anything in the "Your
Name "field.

14
You might like to open the source code for this form in a separate window

The page consists of a JavaScript function called validate_form() that performs


the form validation, followed by the form itself.

CODE

<!DOCTYPEhtml>

<html>

<head>

<script>functionvalidate Form(){

var x =

document.forms["myFo rm"]["fname"].value; if(x==null||x=="")

alert("Name must be filled out");returnfalse;

</script>

</head>

<body>

<formname="myForm" action="usrwlcm.html"o nsubmit="returnvalidate


Form()"m ethod="post"> Name:<inputtype="text" name="fname">

<inputtype="submit"val ue="Submit">

</form>

</body>

</html>

15
OUTPUT

16
RESULT

Thus the JavaScript to validate the form has been executed.

17
Ex. No. : 4 INSTALLATION OF APACHE TOM CAT
Date: WEBSERVER

Apache Tom cat HTTP Server

Apache Tomcat is a Java-capable HTTP server, which could execute special


Java programs known as "Java Servlet" and "Java Server Pages (JSP)".
Tomcat is an open-source project,under the "Apache Software Foundation"
(which also provides the most use, open- source,industrial-
strengthApacheHTTPServer).ThemothersiteforTomcatishttp://tomcat.apache.org.

Alternatively, you can find tomcat via the Apache mother site
@http://www.apache.org.

Tomcat was originally written by James Duncan Davison (then working in Sun)
in 1998,based on an earlier Sun's server called Java Web Server (JWS). It began
at version 3.0 afterJWS2.1 it replaced. Sun sub sequently made Tomcat open-
source and gave it to Apache.

The various Tom cat releases are:

Tomcat3.0(1999):ReferenceImplementation(RI)forServlet 2.2andJSP1.1.

Tomcat4.1 (Sep 2002):RIfor Servlet 2.3 and JSP1.2.

Tomcat5.0 (Dec2003):RIfor Servlet 2.4 andJSP 2.0.

Tomcat6.0 (Feb 2007):RIfor Servlet 2.5 and JSP2.1.

Tomcat7.0 (Jan 2011): RIfor Servlet 3.0,JSP 2.2 and EL2.2.

Tomcat 8.0 (Jun 2014): RI for Servlet 3.1, JSP 2.3, EL 3.0 and
WebSocket 1.0. Tomcat 8.5(June2016)supportsHTTP/2,
OpenSSL,TLSvirtual hostingand JASPIC 1.1.

Tomcat 9.0 (Jan 2018): RIfor Servlet 4.0, JSP 2.3, EL3.0, WebSocket 1.0,
JASPIC 1.1.

Tomcat 10.0 (???):

How to Install Tom cat and Get Started with Java Servlet Programming

18
STEP0:CreateaDirectory to Keep all your Works
I shall assume that you have created a directory called "c:\myWebProject" (for
Windows) or"~\myWebProject" (for Mac OS X) in your earlier exercises. Do it
otherwise. This step is important; otherwise, you will be out-of-sync with this
article and will not be able tofind your files later.

STEP 1: Download and Install Tomcat For Windows

Gotohttp://tomcat.apache.org ⇒ Under "Tomcat 9.0.{xx} Released", where


{xx} is the latest update number ⇒ Click "Download" ⇒ Under "9.0.{xx}" ⇒
Binary Distributions ⇒ Core

⇒"zip"(e.g., "apache-tomcat-9.0.{xx}.zip", about 11 MB).

UNZIP the downloaded file into your project directory "c:\myWebProject".


Tomcat shall be unzipped into directory" c:\myWebProject\apache-tomcat-
9.0.{xx}".

For EASE OF USE, we shall shorten and rename this directory


to"c:\myWebProject\tomcat".

Take note of Your Tomcat Installed Directory. Hereafter, I shall refer to the
Tomcat installed directory as<TOMCAT_HOME>.

Tomcat's Sub-Directories

Take a quick look at the Tom cat installed directory. It contains the these sub-
directories bin: contains the binaries and scripts (e.g.,startup . bat and
shutdown. Bat for Windows; startup .sh and shutdown.sh for Unixes and
MacOS X).

conf:containsthesystem-
wideconfigurationfiles,suchasserver.xml,web.xml,andcontext.xml.

webapps:containsthewebappstobedeployed.YoucanalsoplacetheWAR(WebappAr
chive)filefor deployment here.

19
lib:containstheTomcat'ssystem-
widelibraryJARfiles,accessiblebyallwebapps.Youcouldalso place external JAR
file (such as MySQL JDBC Driver)here.

logs: contains Tomcat's log files. You may need to check for error messages
here. work: Tomcat's working directory used byJSP, forJSP-to-Servlet
conversion.

STEP 2: Createan EnvironmentVariable JAVA_HOME(ForWindows)

You need to create an environment variable (system variable available to all


applications)called "JAVA_HOME", and set it to your JDK installed directory.

Many Java applications (such as Tomcat) require the environment variable


JAVA_HOME to be set to the JDK installed directory.

To set the JAVA_HOME environment variable:

First, find your JDK installed directory. For JDK11, the defaultis " c:\Program
Files\Java\jdk- 11.0.{x}", where "{x} is the update number. Use your "File
Explorer" to find this directory and take note of your update number{x}.

Check if JAVA_HOME is already set. Start a CMD and issue:

Set JAVA_HOME

If you get a message "Environment variable JAVA_HOME not defined",


proceed to the nextstep.

If you get "JAVA_HOME=C:\Program Files\Java\jdk-11.0.{x}", verify that it


is set correctly to your JDK directory.Ifnot,proceed to thenext step.

To set the environment variable JAVA_HOME in Windows 10:

Launch"ControlPanel"⇒(Optional)"SystemandSecurity"⇒"System"⇒Click"Adv
ancedsystem settings" on the left pane.

Switch to"Advanced"tab ⇒Click"EnvironmentVariables"

Under "System Variables" (the bottom pane) ⇒ Click "New" (or Look for
"JAVA_HOME"and "Edit" if it is already set) ⇒ In "Variable Name", enter
"JAVA_HOME"

20
⇒ In "Variable Value", enter your JDK installed directory you noted in Step 1.
(In the latest Windows 10:you can push the "Browse Directory" button and
navigate to the JDK installed directory to avoid typo error.)

To verify, RE-START a CMD (restart is needed to refresh the environment


variables) and issue:

Set JAVA_HOME

JAVA_HOME=c:\Program Files\Java\jdk-11.0.{x}<== Verify


that this is YOUR JDK installed directory

Notes: Windows' environment variables (such as JAVA_HOME, PATH) are


NOT case- sensitive.

STEP3:ConfiguretheTomcatServer

The Tomcat configuration files, in XML format, are located in the "conf" sub-
directory
ofyourTomcatinstalleddirectory,e.g."c:\myWebProject\tomcat\conf"(forWindow
s)or"~/myW
ebProject/tomcat/conf"(forMacOSX).Theimportantconfigurationfilesare:

server.xml web.xmlco ntext.xml

Make a BACKUP of the configuration files before you proceed!!!

Step3(a)"conf\server.xml" –Set the TCP Port Number

Useaprogrammingtexteditor(e.g.,SublimeText,Atom)toopentheconfigurationfile
"server.xml".

The default TCP port number configured in Tomcat is 8080, you may choose
any number between 1024 and 65535, which is not used by existing
applications. We shall choose 9999 in this article. (For production server, you
should use port 80, which is pre-assigned to HTTP server as the default port
number.)

21
Locate the following lines (around Line 69) that define the HTTP connector,
and change port="8080"to port="9999".

<!-- A "Connector" represents an endpoint by which requests are


receivedandresponsesare returned. Documentation at :

Java HTTP Connector:

/docs/config/http.htmlJava AJPConnector:

/docs/config/ajp.htmlAPR(HTTP/AJP)Conne ctor:/docs/apr.html

Defineanon-SSLHTTP/1.1 Connector on port 8080

-->

<Connector port="9999" protocol="HTTP/1.1"connectionTimeou


t="20000"redirectPort="8443"/>

Step3(b)"conf\web.xml" -EnableDirectoryListing

Again,use a programming text editor to open the configuration file"web.xml".

Weshallenabledirectorylistingbychanging"listings"from"false"to"true"forthe"de
fault"servlet. Thisis handyfortest system,but not forproduction
systemforsecurity.

Locatethefollowinglines(aroundLine108)thatdefinethe"default"servlet;andchang
ethe"listings" from"false"to"true".

<servlet>

<servlet-name>default</servlet-name>

<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>

<init-param>

<param-name>debug</param-name>

<param-value>0</param-value>

</init-param>

<init-param>
22
<param-name>listings</param-name>

<param-value>true</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

Step3(c)"conf\context.xml"-EnablingAutomaticReload

We shall add the attribute reloadable="true" to the <Context> element to enable


automaticreload after code changes. Again, this is handy for test system but not
recommended forproduction,dueto theoverhead of detectingchanges.

Locatethe<Context>startelement(aroundLine19),andchangeitto<Contextreloada
ble="true">.

<Contextreloadable="true">

......

......

</Context>

2.5 STEP4:Start TomcatServer

TheTomcat'sexecutableprogramsandscriptsarekeptinthe"bin"sub-
directoryoftheTomcatinstalled directory.

Step4(a)StartServer

ForWindows
IshallassumethatTomcatisinstalledin"c:\myWebProject\tomcat".LaunchaCMDsh
ellandissue: c: //Changedrive

cd \myWebProject\tomcat\bin// Change directory to your Tomcat's binary


directorystartup //Run startup.bat to start tomcatserver

23
Step4(b)Start a Client to Access the Server

Startabrowser(Firefox,Chrome)asanHTTPclient.IssueURL"http://localhost:9999
"toaccessthe
Tomcatserver'swelcomepage.Thehostname"localhost"(withIPaddressof127.0.0.1
)ismeantforlo calloop-back testing within the same machine. For users on the
other machines over the net, they have to use the server's IP address or DNS
domain name in the form of"http://serverHostnameOrIPAddress:9999".
(Optional)TryissuingURLhttp://localhost:9999/examplestoviewtheservletandJS
Pexamples.Tr y running some of the servlet examples.

Step4(c)ShutdownServer

For Windows

You can shutdown the tomcat server byeither:

PressCtrl-ContheTomcatconsole;OR
Run"<TOMCAT_HOME>\bin\shutdown.bat"script.Openanew"cmd"andissue:
c://Changethecurrentdrive
cd\myWebProject\tomcat\bin//ChangedirectorytoyourTomcat'sbinarydirectory
shutdown//Runshutdown.battoshutdowntheserver

RESULT:

Thus the installation of apache Tom cat webserver is verified.

24
Ex. No. : 5 INVOKING SERVLETS FROM HTML
Date: FORMS-SESSION
TRACKING

AIM

To create a simple application to perform session tracking using servlet.

SOFTWAREREQUIRED

Tomcat Server

DESCRIPTION

Session simply means a particular interval of time. Session Tracking is a way to


maintain state(data)of an user. It is also known as session management in
servlet.

Session Tracking Techniques

There are four techniques used in Session tracking:

Cookies

HiddenFormField

URLRewriting

HttpSession

25
ALGORITHM

client.html

Create a web page using HTML form that contains the fields such as text,
password and one submit button.

Set the URL of the server as the value of form’s action attribute.

Run the HTML program.

Submit the form data to the server.

server.java

Define the class server that extends the property of the class Generic Servlet.

Handle the request from the client by using the method service() of Generic
Servlet class.

Get the parameter names from the HTML form by using the method get
ParameterNames().

Get the parameter values from the HTML forms by using the method get
Parameter().

Send the response to the client by using the method of Print Writer class.

CODE

index.html

<!DOCTYPEhtml>

<html>

<head>

<metacharset="ISO-8859-1">

<title>ServletLoginExample</title>

</head>

<body>

<h1>WelcometoLoginApp byCookie</h1>

26
<ahref="login.html">Login</a>|

<ahref="LogoutServlet">Logout</a>|

<ahref="ProfileServlet">Profile</a>

</body>

</html>

link.html

<ahref="login.html">Login</a>|

<ahref="LogoutServlet">Logout</a>|

<ahref="ProfileServlet">Profile</a>

<hr>

login.html

<formaction="LoginServlet"method="post">Name:<inputt
ype="text"name="name"><br>Password:<inputtype="pass
word"name="password"><br>

<inputtype="submit"value="login">

</form>LoginServlet.j avapackagecom.javatpo int;

importjava.io.IOException;i mportjava.io.PrintWriter;
importjavax.servlet.ServletException;i mport
javax.servlet.http.Cookie;importjavax. servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest;im port
javax.servlet.http.HttpServletResponse;publiccl ass
LoginServletextendsHttpServlet{

protected void doPost(HttpServletRequest request, HttpServletResponse


response)throwsServletException,IOException{

response.setContentType("text/html"); PrintWriterout=response.getWriter();

27
request.getRequestDispatcher("link.html").include(request,

response);Stringname=request.getParameter("name");
Stringpassword=request.getParameter("password");

if(password.equals("admin123")){out.print("Y ou are successfully logged


in!");out.print("<br>Welcome,"+name);

Cookie ck=new Cookie("name",name);response.addCo okie(ck);

}else{

out.print("sorry,
usernameorpassworderror!");request.getRequestDispatcher("login.html
").include(request,response);

out.close();

LogoutServlet.javapackage com.javatpoint;import
java.io.IOException;importjava.io.PrintWriter;
importjavax.servlet.ServletException;i

mport javax.servlet.http.Cookie;importjavax. servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest;imp ort
javax.servlet.http.HttpServletResponse;publiccla ss LogoutServlet
extendsHttpServlet{

protected void doGet(HttpServletRequest request, HttpServletResponse


response)throwsServletException,IOException{
28
response.setContentType("text/html"); PrintWriterout=response.getWriter();
request.getRequestDispatcher("link.html").include(request,
response);Cookieck=newCookie("name",""); ck.setMaxAge(0);respon

se.addCookie(ck); out.print("youaresuccessfullylogged out!");

File:ProfileServlet.java

packagecom.javatpoint;

importjava.io.IOException;i mportjava.io.PrintWriter;
importjavax.servlet.ServletException;i mport
javax.servlet.http.Cookie;importjavax. servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest;im port
javax.servlet.http.HttpServletResponse;publiccl

assProfileServletextendsHttpServlet{

protected void doGet(HttpServletRequest request, HttpServletResponse


response)throwsServletException,IOException{

response.setContentType("text/html"); PrintWriterout=response.getWriter();

request.getRequestDispatcher("link.html").include(request,
response);Cookieck[]=request.getCookies();

if(ck!=null){

String name=ck[0].getValue();if(!name.eq uals("")||name!=null){

out.print("<b>Welcome to Profile</b>");out.print("<br>Welcome,"

+name);

}else{

29
out.print("Pleaselogin
first");request.getRequestDispatcher("login.html").include(request,resp onse);

out.close();

web.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http:/
/java.sun. com/xml

/ns/javaee

http://java.sun.com/xml/ns/javaee/web-
app_2_5.xsd"id="WebApp_ID"version="2.5">

<servlet>

<description></description>

<display-name>LoginServlet</display-name>

<servlet-name>LoginServlet</servlet-name>

<servlet-class>com.javatpoint.LoginServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>LoginServlet</servlet-name>

<url-pattern>/LoginServlet</url-pattern>

</servlet-mapping>

<servlet>

30
<description></description>

<display-name>ProfileServlet</display-name>

<servlet-name>ProfileServlet</servlet-name>

<servlet-class>com.javatpoint.ProfileServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>ProfileServlet</servlet-name>

<url-pattern>/ProfileServlet</url-pattern>

</servlet-mapping>

<servlet>

<description></description>

<display-name>LogoutServlet</display-name>

<servlet-name>LogoutServlet</servlet-name>

<servlet-class>com.javatpoint.LogoutServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>LogoutServlet</servlet-name>

<url-pattern>/LogoutServlet</url-pattern>

</servlet-mapping>

</web-app>

OUTPUT

31
RESULT

Thus a simple application has been created for invoking servlets from
HTML forms.

32
Ex. No. : 6 a) CREATION OF THREE-TIER
Date: APPLICATIONS USING JSP AND
DATABASES-FOR CONDUCTING ON-LINE
EXAMINATION

AIM

To create a three-tier application using JSP and Databases for the conduction of
online-examination.

SOFTWARE REQUIRED

TomcatServer

DESCRIPTION

Java Server Pages (JSP) is a technology that helps software developers create
dynamically generated web pages based on HTML, XML, or other document
types. Released in 1999 by Sun Micro systems, JSP is similar to PHP and ASP,
but it uses the Java programming language.

ALGORITHM

Design the HTML page(ExamClient.html)with the following

Create a form to get the input from the user.

User a dio buttons to make various options for the questions.

Set the URL of the server (ExamServer.jsp)as the value of the action attribute.
33
Use submit button to invoke the server and send the form data to the server.

Create the JSP file with the following

Read the input from the client.

Retrieve the answers from the database.

Match the answers from the user with the correct answers from the database
table.

For each correct answer increment the mark by5.

Server displays the mark and result to the client as a response.

CODE

ExamServer.jsp:

<%@pagecontentType="text/html"language="java"import="java.sql.*"%>

<html>

<head>

<title>OnlineExamServer</title>

<styletype="text/css">

body{background-color:black;font-family:courier;color:blue}

</style>

</head>

<body>

<h2style="text-align:center">ONLINEEXAMINATION</h2>

<p>

<ahref="ExamClient.html">BackToMainPage</a>

</p>

<hr/>

34
<%

String

str1=request.getParameter("ans1");String

str2=request.getParameter("ans2");String

str3=request.getParameter("ans3");int

mark=0;Class.forName("sun.jdbc.odbc.Jd bcOdbcDriver");

Connection
con=DriverManager.getConnection("jdbc:odbc:examDS");Statementst

mt=con.createStatement();

ResultSetrs=stmt.executeQuery("SELECT*FROMexamTab");in t i=1;

while(rs.next())

if(i==1)

String dbans1=rs.getString(1);if(str1. equals(dbans1))

mark=mark+5;

if(i==2)

String dbans2=rs.getString(1);if(str2. equals(dbans2))

mark=mark+5;

35
}

if(i==3)

String dbans3=rs.getString(1);

if(str3. equals(dbans3))
{

mark=mark+5;

}i+

+;

if(mark>=10)

out.println("<h4>YourMarkIs : "+mark+"</h4>");

out.println("<h3>Congratulations ...!YouAreEligibleForTheNextRo und..


</h3>");

else

out.println("<h4>YourMarkis:"+mark+"</h4>");

out.println("<h3>Sorry....!!YouAreNotEligible For TheNextRound. . </h3>");

%>

</form>

</body>

36
</html>

ExamClient.HTML:

<html>

<head>

<title>OnlineExamClient</title>

<styletype="text/css">

body{background-color:black;font-family:courier;color:blue}

</style>

</head>

<body>

<h2style="text-align:center">ONLINEEXAMINATION</h2>

<h3>Answerthefollowingquestions(5marksfor eachcorrectanswer)</h3>

<hr/>

<formname="examForm"method="post"action="ExamServer.jsp">

Allcomputersmust have<br/>

<inputtype="radio"name="ans1"value="OperatingSystem">OperatingSystem

<inputtype="radio"name="ans1"value="ApplicationSoftware">ApplicationSoftw
are

<inputtype="radio"name="ans1"value="CD Drive">CDDrive

<inputtype="radio"name="ans1"value="Microsoftword">Microsoftword

<br/><br/>

Theterm PCmeans <br/>

<inputtype="radio"name="ans2"value="PrivateComputer">PrivateComputer

37
<inputtype="radio"name="ans2"value="ProfessionalComputer">ProfessionalCo
mputer

<inputtype="radio"name="ans2"value="PersonalComputer">PersonalComputer

<inputtype="radio"name="ans2"value="PersonalCalculator">PersonalCalculator

<br/><br/>

wasdevelopedby?<br/>

<inputtype="radio"name="ans3"value="Dennis Ritchie">DennisRitchie

<inputtype="radio"name="ans3"value="Stroustrup">Stroustrup

<inputtype="radio"name="ans3"value="David Ritchie">DavidRitchie

<inputtype="radio"name="ans3"value="Charles Babbage">CharlesBabbage

<br/><br/>

<inputtype="submit"value="CheckYourResult"/>

</form>

</body>

</html>

OUTPUT

38
RESULT

Thus a simple web application using JSP and Database had been created for the
conduction of online examination.

39
Ex. No. : 6 b) CREATIONOFTHREE-
Date: TIERAPPLICATIONSUSINGJSPAND
DATABASES-FOR DISPLAYING STUDENT
MARKLIST

AIM

To create a three-tier application using JSP and Databases for displaying the
student mark list.

SOFTWARE REQUIRED

TomcatServer

DESCRIPTION

Java Server Pages (JSP) is a technology that helps software developers create
dynamically generated web pages based on HTML, XML, or other document
types. Released in1999bySun Microsystems, JSP is similar to PHP and ASP
,but uses the Java programming language.

ALGORITHM

Design the HTML page(stud.html) with the following

Create a form to get the input (Register Number)from the user.

Set the URL of the server (marklist.jsp)as the value of the action attribute.

Use submit button to invoke the server and send the form data to the server.

Create the JSP file with the following

Read the parameter value (Register Number) from the form by using the method
get Parameter().

40
Server retrieves the details from the database table with respect to the form
input.

Server displays the mark list to the client as the response.

CODE

marklist.jsp:

<%@pagecontentType="text/html"language="java"import="java.sql.*"%>

<html>

<head>

<title>ThreeTierApplication</title>

<styletype="text/css">

body{color:blue;font-family:courier;text-align:center}

</style>

</head>

<body>

<h2>EXAMINATIONRESULT</h2><hr/>

<%

String str=request.getParameter("regno");Class.forName("sun.jdbc.odbc.Jdb
cOdbcDriver");

Connection
con=DriverManager.getConnection("jdbc:odbc:markDS");Statementst
mt=con.createStatement(); ResultSetrs=stmt.executeQuery("SELECT*FROM
markTab WHERE rno="+str);while(rs.next())

%>

RegisterNo:<%=rs.getObject(1)%><br/> Name:<%=rs.getObject(2)%><br/>

<tableborder="1">

41
<th>SUBJECT</th><th>Mark</th>

<tr><td>Network Programming
andManagement</td><td><%=rs.getObject(3)%></td></tr>

<tr><td>ObjectOrientedAnalysisandDesign</td><td><%=rs.getObject(4)%></td
></tr>

<tr><td>CryptographyandNetworkSecurity</td><td><%=rs.getObject(5)%></td
></tr>

<tr><td>EmbeddedSystems</td><td><%=rs.getObject(6)%></td></tr>

<tr><td>WebTechnology</td><td><%=rs.getObject(7)%></td></tr>

<tr><td>SoftwareRequirementandEngineering</td><td><%=rs.getObject(8)%>
</td></tr>

</table>

<%

%>

<br/>

<ahref="stud.html">Back</a>

</body>

</html>

stud.html

<html>

<head>

<title>ThreeTierApplication</title>

<styletype="text/css">

42
body{color:blue;font-family:courier;text-align:center}

</style>

</head>

<body>

<h2>EXAMINATIONRESULT</h2><hr/>

<form name="f1" method"GET" action="marklist.jsp">EnterYour Reg.No:

<input type="text" name="regno"/><br/><br/>&nbsp;&nbsp;&nb


sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;

<inputtype="submit"value="SUBMIT"/>

</form>

</body>

<html>

OUTPUT

43
RESULT

Thus a simple web application using JSP and Database had been created
displaying student mark list.

44
Ex. No. : 7 PROGRAMS USING XML–SCHEMA–
Date: XSLT/XSL

AIM

To write a XML scheme to generate CD Collection details.

SOFTWAREREQUIRED

Dreamweaver or Notepad and Browser.

DESCRIPTION

In HTML documents, tags are predefined but in XML documents, tags are not
predefined. World Wide Web Consortium(W3C) developed XSL to understand
and style an XML document, which can act as XML based Style sheet
Language.

An XSL document specifies how a browser should render an XML document.

Main parts of XSL Document

XSLT:It is a language for transforming XML documents into various other types
of documents.

XPath: It is a language for navigating in XML documents.

XQuery: It is a language for querying XML documents.

XSL-FO:It is a language for formatting XML documents.

How XSLT Works?


TheXSLTstylesheetiswritteninXMLformat.Itisusedtodefinethetransformationrule
sto be applied on the target XML document. The XSLT processor takes the
XSLT style sheet and applies the transformation rules on the target XML
document and then it generates a formatted document in the form of XML,
HTML, or text format. At the end it is used by XSLT formatter to generate
the actual output and displayed on the end-user.

45
ALGORITHM

Step1:Starttheprogram

Step2: Use Xml Style Sheet code to define link

<?xml-stylesheet type="text/xsl" href="yourxsl.xsl"?> Step3: Use the catalog


tag to define CD collection details.

Step 4: Use the necessary heading for appropriate XML tag.

Step 5: Provide necessary information for CD collection details

Step6: Stop the program

CODE

CDCatalog.xml

<?xmlversion="1.0"encoding="ISO-8859-1"?>

<!--EditedbyXMLSpy® --><?xml-
stylesheettype="text/xsl"href="CDCatalog.xsl"?>

<catalog>

<cd>

<title>EmpireBurlesque</title>

<artist>BobDylan</artist>

<country>USA</country>

<company>Columbia</company>

<price>10.90</price><year>1985</year>

</cd>

<cd>

46
<title>Hideyourheart</title>

<artist>BonnieTyler</artist>

<country>UK</country>

<company>CBSRecords</company>

<price>9.90</price>

<year>1988</year>

</cd>

<cd>

<title>GreatestHits</title>

<artist>DollyParton</artist>

<country>USA</country>

<company>RCA</company>

<price>9.90</price>

<year>1982</year>

</cd>

</catalog>

CDCatalog.xsl

<?xmlversion="1.0"encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transfor
m">

<xsl:templatematch="/">

<html>

<body>

47
<h2>MyCD Collection</h2>

<tableborder="1">

<trbgcolor="#9acd32">

<th>Title</th>

<th>Artist</th>

</tr>

<xsl:for-eachselect="catalog/cd">

<xsl:sortselect="artist"/>

<tr>

<td><xsl:value-ofselect="title"/></td>

<td><xsl:value-ofselect="artist"/></td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

RESULT

Thus an XML application had been created to display CDC at a log using XSL.

48
49
50

You might also like