Final WT Lab Manual - Compressed
Final WT Lab Manual - Compressed
Name _______________________________________________________________________________________
Certified that this is bonafide record of work done by the above student during the year
2023-2024
INTRODUCTION
JAVA: java is one of the most popular programming languages used to create Web
applications and platforms. It was designed for flexibility, allowing developers to write
code that would run on any machine, regardless of architecture or platform. According
to the Java home page, more than 1 billion computers and 3 billion mobile phones
worldwide run Java.
HTML: Hypertext Markup Language (HTML) is the main markup language for creating
web pages and other information that can be displayed in a web browser. HTML is
written in the form of HTML elements consisting of tags enclosed in angle brackets (like
<html>), within the web page content. HTML tags most commonly come in pairs like
<h1> and </h1>, although some tags represent empty elements and so are unpaired, for
example <img>. The first tag in a pair is the start tag, and the second tag is the end tag
(they are also called opening tags and closing tags). In between these tags web
designers can add text, further tags, comments and other types of text-based content.
CSS: Cascading Style Sheets, more commonly known by the abbreviation CSS, are style
sheets that are linked to the XHTML (Extensible Hypertext Markup Language) of the
website. The CSS code allows Web developers to take control of many aspects of their
site, such as fonts, colors, positioning and styling of data, while the XHTML code of the
site deals with the actual content and structure of the website.
SERVLET The Servlet is a Java programming language class used to extend the
capabilities of a server. Although servlets can respond to any types of requests, they are
commonly used to extend the applications hosted by web servers, so they can be
thought of as Java Applets that run on servers instead of in web browsers. These kinds
of servlets are the Java counterpart to other dynamic Web content technologies
such as PHP and ASP.NET.
JSP - Java Server Page: It is a server-side technology; Java Server Pages are an extension
to the Java servlet technology that was developed by Sun. JSPs have dynamic scripting
capability that works in tandem with HTML code, separating the page logic from the
static elements -- the actual design and display of the page -- to help make the HTML
more functional (i.e. dynamic database queries). A JSP is translated into Java servlet
before being run, and it processes HTTP requests and generates responses like any
servlet. However, JSP technology provides a more convenient way to code a servlet.
Translation occurs the first time the application is run. A JSP translator is triggered by
the .jsp file name extension in a URL. JSPs are fully interoperable with servlets. You can
include output from a servlet or forward the output to a servlet, and a servlet can
include output from a JSP or forward output to a JSP. JSPs are not restricted to any
specific platform or server. It was orignially created as an alternative to Microsoft's
ASPs (Active Server Pages). Recently, however, Microsoft has countered JSP technology
with its own ASP.NET, part of the .NET initiative.
AJAX an acronym for Asynchronous JavaScript and XML) is a group of interrelated web
development techniques used on the client-side to create asynchronous web
applications. With Ajax, web applications can send data to, and retrieve data from, a
server asynchronously (in the background) without interfering with the display and
behavior of the existing page. Data can be retrieved using the XMLHttpRequest object.
Despite the name, the use of XML is not required (JSON is often used instead. See AJAJ),
and the requests do not need to be asynchronous
<embed src="yourfile.mid"
Music will begin playing
autostart="true" hidden="false"
when your page is
<embed embed loop="false">
loaded and will only
> object <noembed><bgsound
play one time. A control
src="yourfile.mid"
panel will be displayed
loop="1"></noembed>
to enable your visitors
to stop the music.
<font face="Times New
<font> font Example (Tip)
Roman">Example</font>
<font face="Times New Roman"
<font> font Example (Tip)
size="4">Example</font>
<font face="Times New Roman"
<font> font size="+3" Example (Tip)
color="#ff0000">Example</font>
<form
action="mailto:[email protected]"
>
Name: <input name="Name" value="" Name: (Tip)
size="10"><br> Email:
<form> form
Email: <input name="Email" value="" Submit Query
size="10"><br>
<center><input
type="submit"></center>
</form>
<h1>Heading 1 Example</h1>
<h2>Heading 2 Example</h2>
<h3>Heading 3 Example</h3>
<h1>
heading 1 <h4>Heading 4 Example</h4>
<h2>
heading 2 <h5>Heading 5 Example</h5>
<h3>
heading 3 <h6>Heading 6 Example</h6>
<h4>
heading 4
<h5>
heading 5
<h6>
maxlength="30">
<input type="Submit" value="Submit">
</form>
<input> input field Example 2: Example 2: (Tip)
(Internet
Explorer <form method=post action="/cgi- Submit
) bin/example.cgi">
<input type="text" style="color: #ffffff;
font-family: Verdana; font-weight: bold;
font-size: 12px; background-color:
#72a4d2;" size="10" maxlength="30">
<input type="Submit" value="Submit">
</form>
Example 3:
<table border="2"
bordercolor="#336699" Example 3: (Tip)
cellpadding="2" cellspacing="2"
width="100%"> Column 1 Column 2
<tr>
Row 2 Row 2
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
Example 3:
List of Experiments
Additional Experiments
8. Create a Web Page Design Using Basic Text Formatting tags, Ordered Lists, Unordered
List, &Tables.
AIM:
To develop a webpage using basic text formatting tags, ordered lists, Unordered list and
tables.
ALGORITHM:
STEP 1: Start the program.
STEP 2: Open Notepad and Type the program then save as .html
STEP 3: Open the Browse the location of the file in the local disk.
STEP 4: Stop the Program
PROGRAM:
<html>
<head> <title>Erode Sengunthar Engineering College </title></head>
<body>
<h1><center> <font color="green">Shree Venkateshwara Hi-Tech Engineering
College</font> </center></h1>
<p align="center">
<b>Sri kalivani nager,Othakuthirai,P.Mettupalayam(PO) </b>
<i>Email : [email protected] Web: www.svhec.com</i>
</p>
<hr>
<u><center><h3>
<font color="gray">Department of Computer Science and Engineering</font></h3>
</center></u>
<P><b><font color="red">Highlights </font></p>
<ul>
<li>Campus Wide networking</li>
<li>14 Mbps Internet Connectivity</li>
<li>MoU with leading Industries</li>
</ul>
<P><b><font color="red">Laboratory facilites </font></p>
<table border="1" >
<caption><font color="green"><b>Hardware Details</b></font></caption>
<thead>
<tr>
<th>S. No. </th>
<th>Configuration </th>
<th>Quantity </th>
<tr>
</thead>
<tbody align="center">
<tr>
<td>1 </td>
<td>AMD Processor, 2GB RAM </td>
<td>50 </td>
1
<tr>
<tr>
<td>2 </td>
<td>Core 2 Duo, 2GB RAM </td>
<td>100 </td>
<tr>
<tr>
<td>3 </td>
<td>Dual Core, 2GB RAM </td>
<td>50 </td>
<tr>
<tr>
<td>4 </td>
<td>PIV, 2GB RAM </td>
<td>05 </td>
<tr>
</tbody>
</table>
<P><b><font color="red">Software Details </font></p>
<ol>
<li>Operating Systems</li>
<li>Windows XP, 7, 2003 </li>
<li>Sun Solaris</li>
</ol>
<li>Software Details</li>
<ul>
<li>Adobe Photoshop </li>
<li>Oracle 9i</li>
</ul>
</body>
</html>
OUTPUT:
REULT:
Thus a web page has been created by using Basic Tags.
2
Ex.No: 2
WEB PAGE DESIGN USING FORM COMPONENTS
Date:
AIM:
To develop a webpage using Form Components like Textbox, Label, Checkbox, Radio button,
button ,Text area and
ALGORITHM:
STEP 1: Start the program.
STEP 2: Open Notepad and Type the program then save as .html
STEP 3: Open the Browse the location of the file in the local disk.
STEP 4: Stop the Program
PROGRAM :
<html>
<head> <title>Resume</title>
</head>
<body bgcolor="FFECEC">
<center><h1> <font color="blue">SVHEC --CSE- Online Employment Portal</font>
</h1></center>
<center><h3><font color="green">Enter your details and get link with job
seekers</font></h3></center>
<br>
<form>
<h3>Create your Account</h3>
<table border="0" cellspacing="0" cellpadding="9">
<tr>
<td>Your name:</td>
<td><input type="text" name="name" size="25" maxlength="25" /> </td>
</tr>
<tr>
<td>Email.Id:</td>
<td><input type="text" name="email" size="25" maxlength="25"/> </td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pass" size="25" maxlength="25" /> </td>
</tr>
<tr>
<td>Conform password:</td>
<td><input type="password" name="pass1" size="25" maxlength="25" /> </td>
</tr>
</table>
<h4>Contact Details</h4>
<table border="0" cellspacing="0" cellpadding="9">
<tr>
<td>Current location</td>
3
<td> <select name="city" size="1">
<option value="Che">Chennai
<option value="Slm">Salem
<option value="Cbe">Coimbatore
<option value="Madurai">Madurai
<option value="Trichy">Trichy
</select>
</td>
<td align="right"> Country</td>
<td><select name="country" size="1">
<option value="India">India
<option value="USA">USA
<option value="UK">UK
<option value="Australia">Australia
<option value="can">Canada
</select>
</td>
</tr>
<tr>
<td>Mobile:</td>
<td> <input type="text" name="mobil" size="20" maxlength="15" /></td>
<td><input type="checkbox" name="alert" />Receive alerts in sms </td>
</table>
<h4>Current Personal Details</h4>
<table border="0" cellspacing="0" cellpadding="9">
<tr>
<td>Total Experience</td>
<td><select name="year" size="1">
<option value="year">Year
<option value="Fresher">Fresher
<option value="0">0
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
</select>
</td>
<td><select name="month" size="1">
<option value="month">Month
<option value="0">0
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8">8
<option value="9">9
4
<option value="10">10
<option value="11">11
<option value="12">12
</select>
</td>
</tr>
<tr>
<td>Current Annual Salary</td>
<td><select name="lakh" size="1">
<option value="lakh">lakh
<option value="0">0
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8">8
<option value="9">9
</select>
</td>
<td><select name="Thouasnd" size="1">
<option value="Thousand">Thousand's
<option value="0">0
<option value="1">10
<option value="2">20
<option value="3">30
<option value="4">40
<option value="5">50
<option value="6">60
<option value="7">70
<option value="8">80
<option value="9">90
</select>
</td>
</tr>
<tr>
<td> Country</td>
<td><select name="Ins" size="1">
<option value="Country">Country
<option value="mal">Malasiya
<option value="ind">India
<option value="sig">Singapore
<option value="uk">UK
<option value="us">USA
<option value="cin">China
</select>
</tr>
5
</table>
<table border="0" cellspacing="0" cellpadding="9">
<tr>
<td> Current Industry</td>
<td><select name="Ins" size="1">
<option value="Industry">Industry
<option value="-">
<option value="Infosys">Infosys
<option value="tcs">TCS
<option value="MicroSoft">MicroSoft
<option value="oracle">Oracle
<option value="IBM">IBM
</select>
</td>
</tr>
<tr><td> Functional Area</td>
<td><select name="area" size="1">
<option value="Urarea">your Area
<option value="-">
<option value="Java">Java
<option value=".net">.Net
<option value="C++">C,C++
<option value="Testing">Testing
<option value="pearl">pearl
</select>
</td>
</tr>
<tr>
<td align="right"> Key Skills</td>
<td><textarea rows="2" cols="15" name="skills">
</textarea>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="9">
<tr>
<td> Basic Graduation</td>
<td><select name="Ins" size="1">
<option value="UG">UG
<option value="B.Sc">B.Sc
<option value="B.E">B.E
<option value="B.Tech">B.Tech
<option value="BBA">BBA
</select>
</td>
</tr>
<tr>
<td> Post Graduation</td>
<td><select name="area" size="1">
6
<option value="PG">PG
<option value="Java">M.E
<option value="C">M.Tech
<option value="C++">MCA
</select>
</td>
</tr>
</TABLE>
<h4>Upload Resume</h4>
<form id="form1">
Select a file to upload:
<input type="file" id="fname" size="50" accept="video/mpeg/doc" />
</form>
<p>You don't have a resume presently, you still want a account. Give brief description about
the profile below.</p>
<center><textarea rows="4" cols="40" name="skills">
</textarea></center><br><br>
<h4>Mailer and privacy settings</h4>
<table border="0" cellspacing="0" cellpadding="9">
<tr>
<td> <input type="checkbox" name="job" />job alerts</td>
<td> <input type="checkbox" name="com" />Communication in mobile</td>
</tr>
<tr>
<td> <input type="checkbox" name="res" />Resume service-email</td>
<td> <input type="checkbox" name="other" />Other Promotions</td>
</tr>
</table>
<center><input type="submit" name="sub" value="Register"></center>
</body>
</html>
7
OUTPUT:
RESULT:
Thus a web page has been created by using Html Form Components
8
Create a web page with the following using HTML
Ex.No: 3 a. To embed a map in a web page
b. To fix the hot spots in that map
Date: c. Show all the related information when the hot spots are clicked.
IMAGE MAP
AIM
To create a web page with the following using html
i) to embed an image map in a web page
ii) to fix the hot spots
iii) show all the related information when the hot spots are clicked
ALGORITHM
Step 1: Use the <img> tag to insert the graphic for the image map
Step 2: Define the hot regions for the image and place information between the <map> and
</map> tags
Step 3: The <area> element is always nested inside a <map> tag to create hot region.
Step 4: Show all the related information when the hot spots are clicked
PROGRAM:
Mainpage.html
<html>
<head>
<title>Planets</title>
</head>
<body>
<h3>Click on the planets to watch closer</h3>
<img src="D:\planet.jpg" width="800" height="600" alt="Planets" usemap="#planetmap" />
<map name="planetmap">
<area shape="rect" coords="0,0,143,300" href="sun.html" alt="Sun"/>
<area shape="circle" coords="0,0,400" alt="mercury" href="mer.html"/>
<area shape="circle" coords="0,0,600" alt="venus" href="ven.html"/>
</map>
</body>
</html>
Sun.html
<html><body>
9
<h1>This is Sun</h1>
<h2> The Sun is the star at the center of the Solar System. <br/>
It is almost perfectly spherical and consists of hot plasma interwoven with magnetic fields.
</h2>
<img src="D:\sun.jpg" alt="sun" width=200 height=200/>
</body>
</html>
Mercury.html
<html>
<body>
<h1>This is Mercury.</h1>
<h2>Mercury is the innermost and smallest planet in the Solar System,<br/>
orbiting the Sun once every 87.969 Earth days.
</h2>
<img src="D:\mercur.jpg" alt="mercury" width=200 height=200/>
</body>
</html>
Venus.html
<html>
<body>
<h1>This is Venus</h1>
<h2>Venus is the second planet from the Sun, orbiting it every 224.7 Earth days.<br/>
Venus reaches its maximum brightness shortly before sunrise or shortly after sunset,<br/>
for which reason it has been known as the Morning Star or Evening Star.</h2>
<img src="D:\venus.jpg" alt="venus" height=200 width=200/>
</body>
</html>
OUTPUT
10
RESULT
Thus web page has been created with image map & hot spot successfully to display all related
information when hot spot are clicked.
11
Ex.No: 4 Create a web page with the following.
a. Cascading style sheets.
b. Embedded style sheets.
Date: c. Inline style sheets. Use our college information for the web pages.
ALGORITHM
Step 1: Use various selectors like ID selector, Class selector and Tag selector to create style
sheet.
Step 2: In Internal or External style sheet, an entire CSS document is embedded into the head
section of html document.
Step 3: In External style sheets, a CSS file (a separate document that contain only CSS rules) is
created and linked to the document to which it has to be applied.
Step 4: In Inline style sheets, use style attribute in relevant tag.
PROGRAM:
Mainpage.html
<html>
<head>
<title>
style sheets
</title>
<frameset cols="25%,*">
<frame name="frame1" src="main.html"/>
<frame name="frame2" src="lilly.jpg"/>
<frame name="frame2" src="Internal.html" />
<frame name="frame2" src="Inline.html"/>
<frame name="frame2" src="Internal.html"/>
</frameset>
</head>
</html>
Main.html
<html>
<body bgcolor="lightgreen">
<h3><strong> Different types of CSS </strong></h3>
<h3> <ol type="1">
12
<li>
<a href="Inline.html" target="frame2">Inline CSS</a>
</li>
<li>
<a href="Internal.html" target="frame2">Embedded CSS</a>
</li>
<li>
<a href="External.html" target="frame2">External CSS</a>
</li>
</ol>
</h3>
</body>
</html>
Inline.html
<html>
<head>
<style type="text/css">
.p1
{
color:Darkblue;
background-color:lightblue;
font-size:18px;
padding:0.6 cm;
position:absolute;
border-style:dotted;
border-color:green;
border-width:5px";
}
</style>
</head>
<body>
<h2 style="color:red";font-family:Monotype Corsiva;align:center;">INLINE STYLE
SHEET</h2>
<!-- Inline Style -->
<p style="color:Green;font-weight:bold;font-family:TimesNewRoman;font-size:18px;">
Inline styles are CSS styles that are applied to one html element using the style attribute.
</p>
<br/>
<p class="p1">
Syntax : <br>
<[element name] style="[CSS property]:[property value];">
</p> <br/><br/><br/><br/><br/><br/>
13
</p></style>
</body>
</html>
Internal.html
<html>
<head>
<style type="text/css">
#p1 /*ID Selector */
{
color:Red;
font-size:22px;
}
p /*Tag Selector */
{
font-size:20px;
color:green;
}
.p2 /* Class Selector */
{
font-size:18px;
background-color:lightblue;
color:darkblue;
}
</style>
</head>
<body>
<p id="p1">EMBEDDED STYLE SHEET</p>
<p>An Embedded Style Sheet is specified using the STYLE element within the HEAD section.
</p>
<br/>
<p class="p2">
Syntax: <br/>
<style type="text/css"> <br/>
[Internal CSS Style Sheet] <br/>
</style>
</p>
<body>
</html>
External.html
<html>
<head>
14
<link rel="Stylesheet" TYPE="text/css" href="mystyle.css">
</head>
<body>
<h2 style="color:red";font-family:Monotype Corsiva;text-align:center;">EXTERNAL STYLE
SHEET</h2>
<h3 style="color:Green;font-weight:bold;font-family:TimesNewRoman;font-size:18px;">
An External Style Sheet is specified using the LINK element within the HEAD tag.
</h3>
<p>
Syntax :
<link REL="STYLESHEET" TYPE="text/css" HREF="[Style sheet URL]" >
</p></style>
<br/><br/><br/><br/><br/><br/>
<p style="border-style:groove;">
Example : <link REL="STYLESHEET" TYPE="text/css" HREF="mystyle.css" >
</p></style>
</body>
</html>
mystyle.css
p
{
color:Darkblue;
font-size:18px;
padding:1cm;
position:absolute;
border-style:dotted;
border-color:green;
border-width:2px";
}
OUTPUT
15
RESULT:
Thus a web page has been created by using all types of cascading style sheets successfully.
16
Ex.No: 5
CLIENT SIDE SCRIPTS FOR VALIDATING WEB FORM
CONTROLS USING DHTML
Date:
Java Script:
JavaScript can be used to validate data in HTML forms before sending the content to a server.
Form data that typically are checked by a JavaScript could be:
has the user left required fields empty?
has the user entered a valid e-mail address?
has the user entered text in a numeric field?
has specific length of character?
AIM:
To create client side scripts for validating web form controls using DHTML.
ALGORITHM:
Step 1: Create necessary form controls like text boxes and buttons required for the web form
using html.
Step 2: Using java script validate data in the form.
Step 3: Create script function in head section.
Step 4: Script function is called whenever any one of the field is empty.
Step 5: Finally submit process is successful only after validating the entire form.
PROGRAM:
Validate.html
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function ValidateForm()
{
valid=true;
if (document.form.username.value == "" )
{
alert("\nPlease enter your name ");
username.focus();
valid=false;
}
if (document.form.username.value.length>10)
{
alert("Name should be less than 10 chacter");
username.focus();
valid=false;
}
if ((form.email.value == "" || form.email.value.indexOf('@', 0) == -1) ||
form.email.value.indexOf('.') == -1)
{
17
alert ("\nPlease enter a proper email");
email.focus();
vaild=false;
}
if ((form.radiobutton[0].checked == false) && (form.radiobutton[1].checked== false))
{
alert ("\nPlease choose your gender");
radiobutton.focus();
vaild=false;}
if(form.dropdownlist.selectedIndex == 0)
{
alert ("\nPlease select your branch");
dropdownlist.focus();
vaild=false;
}
if((form.checkbox[0].checked==false)&&(form.checkbox[1].checked==false))
{
alert ("\nPlease check Yes or No");
checkbox.focus();
vaild=false;
}
if(form.textarea.value=="")
{
alert ("\nPlease give your Feedback");
textarea.focus();
vaild=false;
}
alert("Successfully Submitted");
return valid;
}
</SCRIPT>
<STYLE TYPE="TEXT/CSS">
#td1 /*ID Selector */
{
color:darkRed;
font-size:18px;
}
</STYLE>
</HEAD>
<BODY>
<center><h3>FEEDBACK FORM</h3></center>
<center>
<table border="5" cellspacing="2" width="100" cellpadding="3">
<td id="td1">
<FORM name="form" method="POST" onSubmit="ValidateForm()">
Username:
<input type="text" value="" name="username" size=30><br><br>
Email:
<input type="text" value="" name="email" size=30> <br><br>
18
Gender:
<INPUT TYPE="radio" NAME="radiobutton" value="Male">Male
<INPUT TYPE="radio" NAME="radiobutton" value="Female">Female<br><br>
Branch:
<select name="dropdownlist">
<option selected="" value="ps">please select a branch</option>
<option value="EEE">electrical & electronics engg</option>
<option value="CSE">computer science engg</option>
<option value="IT">IT</option>
</select><br><br>
Are you interested in future seminar? <br><br>
<input type="checkbox" name="checkbox" value="Yes" >Yes
<input type="checkbox" name="checkbox" value="No" >No <br><br>
Feedback about today's Seminar<br><br>
<textarea name="textarea" rows="4" cols="40"></textarea>
<br>
<center><input type="button" name="SubmitButton" value="Submit"
OnClick="ValidateForm()">
<input type="reset" value="Reset">
</td>
</TABLE>
</FORM>
</BODY>
</HTML>
OUTPUT
19
RESULT
Thus client side scripting has been created to validate a web form controls using DHTML.
20
Ex.No: 6 INSTALLING & CONFIGURING TOMCAT &
CONVERT THE STATIC WEBPAGES INTO DYNAMIC WEBPAGES
Date: USING SERVLETS
AIM:
To Convert the static WebPages into dynamic WebPages using servlets
ALGORITHM:
STEP 1: Start the program.
STEP 2: Develop client side application using HTML.
STEP 3: Enter the register number at the client side HTML From.
STEP 4: Invoke the servlet form the client side application.
STEP 5: Develop a Http base servlet to display student exam results.
STEP 6: Read the register from the request object of servlet interface.
STEP 7: Check the availability of the register in the data base using JDBC Connectivity.
STEP 8: If the register number is available retrieve the results using executeQuery() method.
STEP 9: Send back the result to the client via response object.
STEP 10: Stop the program.
Environment Used
JDK 6 (Java SE 6)
Apache Tomcat 6.x
Windows OS
JDK Initialization
JDK should be installed with proper environment set up. Installing the JDK and
setting up the environment. Installing JDK automatically installs JRE.
21
22
PROGRAM:
Text.html
<HTML>
<HEAD><TITLE> Results of a student</TITLE></HEAD>
<body>
<center><h3> University Examination Results July 2008 </h3></center>
<form method = "GET" action="NewServlet">
Enter Register Number : <input type ="text" name="regno" value= " ">
<input type ="submit" value="GetResult">
</form>
</body>
</HTML>
NewServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class NewServlet extends HttpServlet {
Connection con;
Statement st;
ResultSet rs;
public void init()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:it","","");
System.out.println("Connection Created");
st= con.createStatement();
}
catch(Exception e)
{
System.out.println(e);
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
ResultSet rs;
String qr="";
try
{
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title> Results </title>");
23
out.println("</head>");
out.println("<body>");
out.print("<h3>Results of " + request.getParameter("regno")+"</H3>");
rs=st.executeQuery("select * from rtable where
regno='"+request.getParameter("regno")+"'");
out.println("<h3><pre> <FONT COLOR='BLUE'> Subject Name Grade
</FONT></H3></pre>");
if(rs.next())
{
out.print("<h4> Web Technology : " + rs.getString(2)+"</h4>");
out.print("<h4> Enterprise Computing : " + rs.getString(3)+"</h4>");
out.print("<h4> C#.NET Programming : " +rs.getString(4)+"</h4>");
out.print("<h4> Java Programming : " + rs.getString(5)+"</h4>");
out.print("<h4> Principles of Management : " + rs.getString(6)+"</h4>");
}
else
{
out.println("<h1>Invalid Register Number</h1>");
} }
catch(Exception e)
{
out.println("<h1>"+qr+"<br>"+e+"</h1>");
}
finally
{
out.println("</body>");
out.println("</html>");
out.close();
}
}
}
24
OUTPUT:
Client
Server
25
Client
Server
RESULT:
Thus to convert the static WebPages into dynamic WebPages using servlets has been
developed, executed and verified successfully.
26
Ex.No: 7 CREATE JAVA SERVLET PROGRAM & INVOKE SERVLETS FROM
HTML FORMS
Date:
Servlet:
Servlets are simple java programs that run on the servers. Hence it is called as servlet. Servlet
make use of java extension classes in the packages javax.servlet and javax.servlet.http.
AIM:
To write java program to invoke servlets from HTML forms
ALGORITHM:
1. Create Employee form using html
2. Create java servlet program and save as classname.java
3. Compile java program.
4. Copy class file and save it in
C:\Program Files\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes
PROGRAM:
<html>
<head>
<title>Employee Details</title>
</head>
<body>
<center>
<form name="my" method="post" action="http://localhost:8080/examples/servlet/my">
<h2>Enter employee details in following fields</h2>
<table>
<tr>
<td><h3>Employee ID</h3></td>
<td><input type="text" name="EID" size="25" value=""></td>
</tr>
<tr>
<td><h3>Employee Name</h3></td>
<td><input type="text" name="EName" size="25" value=""></td>
</tr>
<tr>
<td><h3>Employee Address</h3></td>
27
<td><textarea rows="2" cols="20" name="EAddress"></textarea></td>
</tr>
<tr>
<td><h3>Phone</h3></td>
<td><input type="text" name="Phone" size="25" value=""></td>
</tr>
<tr>
<td><h3>Salary</h3></td>
<td><input type="text" name="ESal" size="25" value=""></td>
</tr>
</table>
<input type="submit"value="submit">
</form>
</center>
</body>
</html>
Invoking Servlets
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class my extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)
throws ServletException,IOException
{
PrintWriter out=res.getWriter();
Enumeration en=req.getParameterNames();
while(en.hasMoreElements())
{
String name_received=(String)en.nextElement();
out.print(name_received+"=");
String value_received=req.getParameter(name_received);
out.println(value_received);
out.println("");
}
out.close();
}
}
OUTPUT
28
C:\>cd C:\Program Files\Java\jdk1.6.0\bin
RESULT
Thus a java program has been written to invoke Servlet from HTML form.
29
Ex.No: 8 SESSION TRACKING USING HIDDEN FORM FIELDS AND TRACKING
FOR A HIT COUNT
Date:
AIM:
To write a program Session Tracking Using Hidden Form Fields and Tracking for a Hit Count
PROCEDURE:
STEP 1: Start the Program
STEP 2: Develop a Servlet application for Session tracking using Hidden Filed
STEP 3: Develop a Servlet application for Session tracking Hit Count Process.
STEP4: Stop the Program
PROGRAM:
hidden form fields
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ShoppingCartViewerHidden extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<HEAD><TITLE>Current Shopping Cart Items</TITLE></HEAD>");
out.println("<BODY>");
// Cart items are passed in as the item parameter.
String[] items = req.getParameterValues("item");
// Print the current cart items.
out.println("You currently have the following items in your cart:<BR>");
if (items == null) {
out.println("<B>None</B>");
}
else {
out.println("<UL>");
for (int i = 0; i < items.length; i++) {
out.println("<LI>" + items[i]);
}
out.println("</UL>");
}
// Ask if the user wants to add more items or check out.
// Include the current items as hidden fields so they'll be passed on.
out.println("<FORM METHOD=GET>"); // submit to self
if (items != null) {
for (int i = 0; i < items.length; i++) {
out.println("<INPUT TYPE=HIDDEN NAME=item VALUE=\"" +
items[i] + "\">"); }
30
}
out.println("Would you like to<BR>");
out.println("<INPUT TYPE=SUBMIT VALUE=\" Add More Items \">");
out.println("<INPUT TYPE=SUBMIT VALUE=\" Check Out \">");
out.println("</FORM>");
out.println("</BODY></HTML>");
}
}
OUTPUT
31
count = new Integer(1);
else
count = new Integer(count.intValue() + 1);
session.setAttribute("tracker.count", count);
out.println("<HTML><HEAD><TITLE>SessionTracker</TITLE></HEAD>");
out.println("<BODY><H1>Session Tracking Demo</H1>");
// Display the hit count for this page
out.println("You've visited this page " + count +
((count.intValue() == 1) ? " time." : " times."));
out.println("<P>");
out.println("<H2>Here is your session data:</H2>");
Enumeration enum = session.getAttributeNames();
while (enum.hasMoreElements()) {
String name = (String) enum.nextElement();
out.println(name + ": " + session.getAttribute(name) + "<BR>");
}
out.println("</BODY></HTML>");
}
}
OUTPUT:
RESULT
Thus a java servlet program has been written and executed successfully.
32
Ex.No: 9 CREATE THREE-TIER APPLICATIONS USING
JSP AND DATABASE
Date:
JSP:
JSP provide excellent server side scripting support for creating database driven web
applications.
Java Server Pages (JSP) technology is the Java platform technology for delivering dynamic content
to web clients in a portable, secure and well-defined way.JPS pages are high level extension of
servlet and it enables the developers to embed java code in html pages. JSP files are finally
compiled into a servlet by the JSP engine. Compiled servlet is used by the engine to serve the
request.
AIM:
To create three-tier application using JSP and databases.
i) for conducting on-line examination.
ii) for displaying student mark list.
ALGORITHM
Step 1: Create a HTML program in which some questions are displayed. The user can select
the appropriate answer for each question and then user has to click the submit
button in order to submit these answers to the web server.
Step 2: Create a JSP which gets invoked when you click submit button on your HTML form.
This JSP will get all the values from the HTML form. It will compute the total marks of
that corresponding student. Then data will be sent to database.
Step 3: Create a database by specifying the field names and provide database connectivity.
33
Step 2 : Browse the location and Save in C: and choose MS Access 2000 format
34
Step 5: Double click Table1 and give value s
Step 6: Save and Close the window. Next Step is to create database connectivity.
35
Step 7: Go to Start >Control Panel>Administrative Tools >ODBC>User DSN tab
Step 8: Give Data Source Name, Description & Select mdb file.
HTML PROGRAM:
<html>
<head>
<title>Online Examination</title>
</head>
<body>
36
<p><b><center><font size="10">ONLINE EXAMINATION</font></center></b></p>
<form name="frm1" action="http://localhost:8080/examples/jsp/disp.jsp">
  <font size="5"> Seat number:<input type="text" name="tb1" size="10" />
Name:<input type="text" name="tb2" size="10" align="right" /><br/><br/><br/>
</font><font size="4">
1.Which of these is a looping statement?<br/>
<input type="radio" name="r1" value="0"/>Switch
    <input type="radio" name="r1" value="0"/>If-else
    <input type="radio" name="r1" value="2"/>Do-while
    <input type="radio" name="r1" value="0"/>Try<br/><br/>
2.Is java implementing OOPS?<br/>
<input type="radio" name="r2" value="2"/>Yes
   <input type="radio" name="r2" value="0"/>No<br/><br/>
3.What is HTTP?<br/>
<input type="radio" name="r3" value="0"/>HTML Tag
    <input type="radio" name="r3" value="2"/>Protocol
    <input type="radio" name="r3" value="0"/>Class
    <input type="radio" name="r3" value="0"/>None Of The
Above<br/><br/>
4.Which of the following is wrong?<br/>
<input type="radio" name="r4" value="0"/>int x=10;
    <input type="radio" name="r4" value="0"/>int a[]={2,3};
    <input type="radio" name="r4" value="2"/>Strin s="test";
    <input type="radio" name="r4" value="0"/>All Of The Above<br/><br/>
5.What is the abbreviation of OS?<br/>
<input type="radio" name="r5" value="0"/>Operator Searching
    <input type="radio" name="r5" value="0"/>Operation Solving
    <input type="radio" name="r5" value="0"/>Ontological Solving
    <input type="radio" name="r5" value="2"/>Operating
Systems<br/><br/>
</font>
<center><input type="submit" value="submit"/></center>
</form>
</body>
</html>
37
<th>Seat_no</th>
<th>Name</th>
<th>Marks</th>
</tr>
<%try
{
int m1=Integer.parseInt(request.getParameter("r1"));
int m2=Integer.parseInt(request.getParameter("r2"));
int m3=Integer.parseInt(request.getParameter("r3"));
int m4=Integer.parseInt(request.getParameter("r4"));
int m5=Integer.parseInt(request.getParameter("r5"));
String s1=request.getParameter("tb1");
String s2=request.getParameter("tb2");
int marks=m1+m2+m3+m4+m5;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn","","");
Statement st=con.createStatement();
st.executeUpdate("insert into Table1(Seatno,Sname,Mark)"+"values('"+ s1 +"','"+ s2 +"','"+
marks +"')");
ResultSet rs=st.executeQuery("select * from Table1");
while(rs.next())
{
%>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
</tr>
<%
}
st.close();
con.close();
}
catch(SQLException e){}
%>
</body>
</html>
38
OUTPUT
39
Updated in Database
RESULT
Thus three tier applications were created using JSP and databases to display online
examination mark
40
Ex.No: 10
CREATE AN XML DOCUMENT WHICH CONTAINS 10 USERS INFORMATION.
Date:
AIM:
Write a XML document, which contains 10 users information. Write a program, which takes User
Id as an input and returns the user details by taking the user information from the XML document.
DESCRIPTION:
XML, or Extensible Markup Language, is a markup language that you can use to create
your own tags. It was created by the World Wide Web Consortium (W3C) to overcome the
limitations of HTML, the Hypertext Markup Language that is the basis for all Web pages. Like HTML,
XML is based on SGML -- Standard Generalized Markup Language. Although SGML has been used in
the publishing industry for decades, its perceived complexity intimidated many people that
otherwise might have used it (SGML also stands for "Sounds great, maybe later"). XML was designed
with the Web in mind.
PROGRAM:
student.dtd:
<!ELEMENT student(rollnum,name,parntname,branch,year,addr,email,phno)>
<!ELEMENT roll_no(#PCDATA)>
<!ELEMENT name(first_name,last_name)>
<!ELEMENT first_name(#PCDATA)>
<!ELEMENT last_name(#PCDATA)>
<!ELEMENT father_name(fname,mname,lname)>
<!ELEMENT first_name(#PCDATA)>
<!ELEMENT last_name(#PCDATA)>
<!ELEMENT branch(#PCDATA)>
<!ELEMENT year(#PCDATA)>
<!ELEMENT address(door_no,street,city)>
<!ELEMENT door_no(#PCDATA)>
<!ELEMENT street(#PCDATA)>
<!ELEMENT city(#PCDATA)>
<!ELEMENT email(#PCDATA)>
<!ELEMENT phno(#PCDATA)>
student.xsd:
<xs:schema>
<xs:element name="student">
<xs:complextype>
<xs:sequence>
<xs:element name="roll_no" type="xs:string"/>
<xs:element name="name">
<xs:complextype>
<xs:sequence>
<xs:element name="first_name" type="xs:string"/>
<xs:element name="last_name" type="xs:string"/>
41
</xs:sequence>
</xs:complextype>
</xs:element>
<xs:element name="father-name">
<xs:complextype>
<xs:sequence>
<xs:element name="first_name" type="xs:string"/>
<xs:element name="last_name" type="xs:string"/>
</xs:sequence>
</xs:complextype>
</xs:element>
<xs:element name="branch" type="xs:string"/>
<xs:element name="year" type="xs:integer"/>
<xs:element name="addr">
<xs:complextype>
<xs:sequence>
<xs:element name="door-no" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:sequence>
</xs:complextype>
</xs:element>
<xs:element name="email" type="xs:string"/>
<xs:element name="phno" type="xs:integer"/>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:schema>
student.xml:
<?xml version="1.0" ?>
- <student xmlns:xsi="xmlschema-instance"
xsi:SchemaLocation="student.xsd">
<roll_no>08A01D2501</roll_no>
- <name>
<first_name>A</first_name>
<Last_name>Aruna</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch>computer engineering</branch>
<year>1ST Year</year>
- <address>
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
<email>[email protected]</email>
42
<phno>9949643372</phno>
<roll_no>08A01D2501</roll_no>
- <name>
<first_name>Prathap</first_name>
<Last_name>Rudra</Last_name>
</name>
- <father_name>
<first_name>Venkateswara </first_name>
<Last_name>B</Last_name>
</father_name>
<branch> computer engineering (mtech) </branch>
<year>1st Year</year>
- <address>
<door-no>door no 603/n</door-no>
<street>Recoloney</street>
<city>Delhi</city>
</address>
<email>[email protected]</email>
<phno>9866145423</phno>
<roll_no>08A01D2503</roll_no>
- <name>
<first_name>Ramesh</first_name>
<Last_name>Kumar</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch> computer engineering(mtech) </branch>
<year>1st Year</year>
- <address>
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
<email>[email protected]</email>
<phno>9985150379</phno>
<roll_no>08A01D2504</roll_no>
- <name>
<first_name>kishore</first_name>
<Last_name>Galla</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch> Computer engineering (mtech) </branch>
<year>1st Year</year>
- <address>
43
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
<email>[email protected]</email>
<phno>990837394</phno>
<roll_no>08A01D2505</roll_no>
- <name>
<first_name>Madhu</first_name>
<Last_name>Garlapati</Last_name>
</name>
- <father_name>
<first_name>Venkateswara</first_name>
<Last_name>Rao</Last_name>
</father_name>
<branch> commputer engineering (mtech) </branch>
<year>1st Year</year>
- <address>
<door-no>32-15/1-44</door-no>
<street>B.R.Nagar-1</street>
<city>Gurgaon</city>
</address>
<email>[email protected]</email>
<phno>9908005778</phno>
</student>
Usevalidation.Html
<html>
<head>
<title>Login Form</title>
</head>
<body leftmargin=75 topmargin=75 bgcolor=white>
<form method=Get action="http:127.0.0.1:8080\validation">
UserName <input type=text name=user>
<br><br>
Password <input type=password name=pass>
<br><br>
<input type=submit value=submit>
<input type=reset name=cancel>
</form>
</body>
</html>
44
OUTPUT:
RESULT:
Thus a XML document with 10 user’s has been written and executed successfully.
45