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

Webtech Lab Manual

The document is a lab manual for a web technologies course (CCS375) that outlines various experiments related to web development using HTML, CSS, JavaScript, and Java. It includes objectives, a list of experiments, and detailed instructions for creating web pages, validating forms, and using web servers and databases. Each experiment is designed to teach specific skills in web technologies and programming.

Uploaded by

vardhinijothi11
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)
2 views

Webtech Lab Manual

The document is a lab manual for a web technologies course (CCS375) that outlines various experiments related to web development using HTML, CSS, JavaScript, and Java. It includes objectives, a list of experiments, and detailed instructions for creating web pages, validating forms, and using web servers and databases. Each experiment is designed to teach specific skills in web technologies and programming.

Uploaded by

vardhinijothi11
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/ 39

WEB TECHNOLOGIES

LAB MANUAL
CCS375

i
INDEX

Page
S. No NAME OF THE EXPERIMENTS No
Create a webpage with the following using HTML.
 To embed an image maping a webpage.
1.  To fix the hotspots. 1
 Show all the related information when the hotspots are clicked.

2. Create a webpage with all types of Cascading style sheets 8

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

4. Installation of Apache Tomcat webserver. 15

5. Write programs in Java using Servlets:

i. To invoke servlets from HTML forms 19

ii. Session Tracking 22

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


and Databases
i. For conducting on-line examination 26

ii. For displaying student marklist.Assume that student information is


32
Available in a database which has been stored in a database server

7. Programs using XML–Schema–XSLT/XSL 35

ii
CCS375 WEB TECHNOLOGIES LABORATORY
OBJECTIVES
 To understand different Internet Technologies
 To learn java-specific web services architecture
 To Develop webapplications using frameworks

LIST OF EXPERIMENTS
1. Create a webpage with the following using HTML.
• To embed an image maping a webpage.
• To fix the hotspots.
• Show all the related information when the hotspots are clicked.
2. Create a webpage with all types of Cascading style sheets.
3. Client Side Scripts for Validating Web Form Controls using DHTML.
4. Installation of Apache Tomcat web 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 marklist.Assume that student information is
available in a database which has been stored in a database server.
7. Programs using XML–Schema–XSLT/XSL.
EX.NO:1 CREATING A WEBPAGE USING IMAGEMAP
DATE :

AIM : To create a webpage with the following using HTML:


i) To embed an imagemaping a webpage.
ii) To fix the hotspots.
iii) Show all the related information when the hotspots are clicked.

ALGORITHM:
Step1: Open notepad and type the HTML coding for home page home.Html which has
an image map using <MAP>tag and create some hotspots.

Step2: Hotspots are created by including a link at required coordinate position using<a>tag
which directs to its corresponding webpages
Step 3: Write the coding for all the link web pages
Step 4: Run the home. Html in suitable web browser
Step 5: Display output.

PROGRAM:

home.html
<html>
<head>
<title>Home-States of India!!!</title>
</head>
<body bgcolor="gold">
<h1><u><center>Republic of India</center></u></h1>
<p>
India is the Seventh Largest country in the world by geographical are
a,these cond most Populous country with over 1.3billion people,India is
avast South Asian country with diver seter rain – from Himalayan
peaks to Indian Ocean coastline and history reaching back 5millennia.
.India is a federal constitutional republic with a parliamentary de
mocracy consisting of 28states and 7Union Territories.</p>
<center>
<img align="center"width="275"height="290"alt="India"src="IndiaMap.jpg"usemap="#indi
a"ismap="ismap">
<mapname="india">
<areashape="circle"coords="100,200,10"href="ANDHRAPRADESH.html"alt="Learn
about andra">
<areashape="circle"coords="70,275,10"href="KERALA.html"alt="Learn about kerala">
<areashape="circle"coords="70,210,20"href="KARNATAKA.html"alt="Learn about
karnata ka">
<areashape="circle"coords="100,250,20"href="TAMILNADU.html"alt="Learn about
tamilnadu">
</map></center>
<h2>Features</h2>
<ul>
<li><b>Population</b>-133.92crores(2019).
<li><b>Capital</b>-NewDelhi
<li><b>Largest City</b>-Mumbai
<li><b>Currency</b>-IndianRupee
<li><b>Time Format</b>-IST(UTC+5:30)
<li><b>National Sport</b>-Hockey
<li><b>Current PM</b>-NarendraModi
<li><b>Current President</b>-PranabMukherjee
</li>
</ul>
<h2><b>To view details of southern states please click on the specified area in the map!</b>
</h2>
</body>
</html>
Tamilnadu.html
<html>
<head><title>TamilNadu-India</title></head>
<bodybgcolor="pale green">
<h1><center>TamilNadu</center></h1>
<h3>is one of the 29states of India.Its capital and largest city is Chennai.TamilNadu lies in the
southern most part of the Indian Peninsula and It is bordered by the States of
Puducherry,Kerala,Karnataka,AndhraPradesh
</h3><h3>
<ul>
<li>Districts<i>-37</i>
<li>Capital City<i>-Chennai</i>
<li>Largest City<i>-Chennai</i>
<li>Governor<i>-BanwarilalPurohit</i>
<li>Chief Minister<i>-Palanisamy</i>
<li>Population<i>-80,351,195</i>
<li>Tourist spots<i>- Mamallapuran,Ooty,Kodaikanal,Marina,MuduraiMeenakshi Amman
Temple,Thanjavur etc.,</i>
</ul>
<ahref="Home.html">back</a>
</body>
</html>

andhrapradesh.html
<html>
<head><title>AndhraPradesh-India</title></head>
<body bgcolor="tan">
<h1><center>Andhra Pradesh</center></h1>
<h3>A.P.,is a state situated on the south eastern coast of India.It is India's fourth
largest state by are and fifth largest by population.</h3>
<h3>
<ul>
<li>Districts<i>-13</i>
<li>CapitalCity<i>-Hyderabad</i>
<li>LargestCity<i>-Hyderabad</i>
<li>Governor<i>-BISWABHUSANHARICHARAN</i>
<li>ChiefMinister<i>-Y.S.JAGANMOHANREDDY</i>
<li>Population<i>-91,103,010</i>
<li>Tourist spots<i>-
TirumalaTirupati,Guntur,GolcondaFort,Chandragiri,Arakuvalley,Falakn
uma Palace etc.,</i>
</ul>
<ahref="Home.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>-B.S.YEDIYURAPPA</i>
<li>Population<i>-68,308,304</i>
<li>Tourist spots<i>-GolGumbaz,MysorePalace,Keshava Temple etc.,</i>
</ul>
</h3>
<ahref="Home.html">back</a>
</body>
</html>

Kerala.html
<html>
<head><title>Kerala-India</title></head>
<body bgcolor="indianred">
<h1><center>Kerala</center></h1>
<h3>
<ul>
<li>Districts<i>-14</i>
<li>CapitalCity<i>-Thiruvanandapuram</i>
<li>LargestCity<i>-Thiruvanandapuram</i>
<li>Governor<i>-ARIFMOHAMMADKHAN</i>
<li>ChiefMinister<i>-PINARAYIVIJAYAN</i>
<li>Population<i>-34,545,868</i>
<li>Touristspots<i>-
EdakkalCaves,Palayur,KovalamBeach,Munnar,Kochi,Alapuzha etc.,</i>
</ul>
<ahref="Home.html">back</a>
</h3>
</body>
</html>

OUTPUT:
Result:
Thus a web page with given specifications was created and its output was
verified
EX.NO:2 CREATING A WEBPAGE WITH CASCADING STYLE SHEET
DATE :
AIM:

To create a webpage with the following using html to embedded the style sheet

ALGORITHM:

Step1: Create html file with the styletag,inside head tag.

Step2: Set the style such as font-family,font-size,color,left etc,for the heading

h1,h2,…h6 and respectively.

Step3: Close the headtag.

Step4: Specify the heading and information required inside the body tag.

Step5: Close the opened tag.

PROGRAM:

<!DOCTYPEhtmlPUBLIC"-////W3C//DTDXHTML1.0
TRANSTION//EN"http://www.w3.org/TR/html1/DTD/html11.dtd>

<htmlxmlns="http://www.w3org/1999/xhtml">
<head>
<title>Embedded stylesheet</title>
<styletype="text/css">h1
{
font-family:arial;
color:green;
}
h2
{
font-family:arial;
color:red;left:20px
}
h3
{
font-family:arial;
color:blue;
}
p
{
font-sise:14pt;
font-family:verdana
}
</style>
</head>
<body>
<h1>
<center>This is created using embedded style sheet
</center>
</h1>
<h2>This line is allingned left and red colored;
</h2>
<p>
The embedded style sheet is the most commonly used style sheet
This paragragh is return in verdana font with font size of 14.
</p>
<h3>
This is a blue<ahref="color name.html">colored</a>line
</h3>
</body>
</html>

OUTPUT:

RESULT:
Thus creation of an webpage using cascading style sheet has been developed
successfully.

.
EX.NO:3 CLIENTSIDE SCRIPTS for validating web form control using DHTML
DATE:
AIM:

To develop a program for validating webform control using DHTML.

ALGORITHM:

Step1: Start the program.


Step2: Define the title with in the tag.
Step3: Give the script type with in the scripttag.
Step4: Validate each and every column as the box with the if condition.
Step5: If empty value are given or the block tem are next then it is verified with
certain condition.
Step6: If values isempty the namessage is been displayed.
Step7: Form is designed with GUI tool is description.
Step8: All buttons are processed accordingly.
Step9: Stop the program.

PROGRAM:
//Webforms.html
<html>
<head>
<script
type='text/javascript'>fu
nctionformValidator()
{
varfirstname=document.getElementById('firstname');
varlastname=document.getElementById('lastname');
var addr=document.getElementById('addr');
varzip=document.getElementById('zip');
var
Countries=document.getElementById('Countries');varu
sername=document.getElementById('username'); var
email=document.getElementById('email');
vardd=document.getElementById('dd');
var
mm=document.getElementById('mm');
varyyyy=document.getElementById('yyyy');
var
comment=document.getElementById('comment');var
password=document.getElementById('password');
if(isAlphabet(firstname,"Please enter only letters for your Firstname"))
{
if(isAlphabet(lastname,"Please enter only letters for your Last name"))
{
if(isNumeric(dd,"Please enter a date"))
{
if(madeSelection(mm,"Please Choose"))

{
9
if(isNumeric(yyyy,"Please enter a year"))
{
if(isAlphanumeric(addr,"Enter Numbers and letters only for address"))
{
if(isNumeric(zip,"please enter a valid zipcode"))
{
if(madeSelection(Countries,"Please Choose"))
{
if(lengthRestriction(username,6,8))
{
if(isAlphanumeric(password,"Enter Numbers and letters only for password"))
{
if(emailValidator(email,"Please enter a valid email address"))
{
if(notEmpty(comment,"Please fill the comment"))
{
document.write("<b><i>Thank's for submitting your
details</i></b>");alert("Successful Entry!!");
returntrue;
}}}}}}}}}}}}
returnfalse;
}
functionnotEmpty(elem,helperMsg)
{
if(elem.value.length==0)
{
alert(helperMsg)
;elem.focus();
return false;
}
returntrue;
}
functionisNumeric(elem,helperMsg)
{
var numericExpression=/^[0-9]+$/;
if(elem.value.match(numericExpression))
{
returntrue;
}
else
{
alert(helperMsg)
;elem.focus();
return false;
}
}
functionisAlphabet(elem,helperMsg)
{
var alphaExp=/^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)
)
{
10
returntrue;
}
else
{
alert(helperMsg);
elem.focus()
;returnfalse;
}
}
functionisAlphanumeric(elem,helperMsg)
{
varalphaExp=/^[0-9,a-z a-z,0-9, A-ZA-Z,-0-9.
]+$/;if(elem.value.match(alphaExp))
{
returntrue;
}
else
{
alert(helperMsg)
;elem.focus();
return false;
}
}
functionlengthRestriction(elem,min,max)
{
var unput=elem.value;
if(unput.length>=min&&unput.length<=max)
{
returntrue;
}
else
{
alert("Please enter between
"+min+"and"+max+"charactters");elem.focus();
returnfalse;
}
}
functionmadeSelection(elem,helperMsg)
{
if(elem.value=="PleaseChoose")
{
alert(helperMsg)
;elem.focus();
return false;
}
else
{
returntrue;
}
}
functionemailValidator(elem,helperMsg)
{
11
varemailExp=/^[0-9a-z.a-z0-9]+\@[a-z]+\.[a-
z]{2,4}$/;if(elem.value.match(emailExp))
{
returntrue;
}
else
{
alert(helperMsg)
;elem.focus();
return false;
}
}
</script>
<h1><center><b><fontcolor="#347235">Please
Enter YourDetails</font></b></center></h1>
</head>
<bodybgcolor="LIGHTGREEN">
<hr>
<formonsubmit='returnformValidator()'height="50%">
<tableheight="50%"border="3pt"align="center">
<tr><td><b><fontcolor="#347235">First
Name:</font></b></td><td><inputtype='text'id='f
irstname'/></td></tr><br />
<tr><td><b><font color="#347235">Last
Name:</font></b></td><td><inputtype='text'id='lastname'/></td></tr><br
/>
<tr><td><b><fontcolor="347235">Dateof
Birth(dd/mm/yyyy):</font></b></td><td><input
type='text' id='dd' />
<selectid='mm'>
<option>PleaseChoose</option>
<optionvalue="1">Jan</option>
<optionvalue="2">Feb</option>
<optionvalue="3">Mar</option>
<optionvalue="4">Apr</option>
<optionvalue="5">May</option>
<optionvalue="6">Jun</option>
<optionvalue="7">Jul</option>
<optionvalue="8">Aug</option>
<optionvalue="9">Sep</option>
<optionvalue="10">Oct</option>
<optionvalue="11">Nov</option>
<optionvalue="12">Dec</option>
</select>
<inputtype='text'id='yyyy'/></td></tr><br/>

<tr><td><b><font
color="#347235">Address:</font></b></td><td><inputtype='text'i
d='addr'/></td></tr><br />
<tr><td><b><font color="#347235">Zip
code:</font></b></td><td><inputtype='text'id='zip'/></td></tr><br/>
<tr><td><b><font
color="#347235">Countries:</font></b></td><td><selectid='Countries'>
<option>PleaseChoose</option>
<optionvalue="UnitedKingdom">UnitedKingdom</option>
<optionvalue="Afghanistan">Afghanistan</option>
<optionvalue="America">America</option>
<optionvalue="India">India</option>
<optionvalue="Tanzania">Tanzania</option>
<optionvalue="Zimbabwe">Zimbabwe</option>
<optionvalue="Switzerland">Switzerland</option>
</select></td></tr><br/>
<tr><td><b><font color="#347235">Username(6-8
characters):</font></b></td><td><inputtype='text'id='username'
/></td></tr><br/>
<tr><td><b><font
color="#347235">Password:</font></b></td><td><inputtype='password'id='password
' /></td></tr><br />
<tr><td><b><font
color="#347235">Email:</font></b></td><td><inputtype='text'id
='email' /></td></tr><br />

<tr><td><b><font
color="#347235">Comment:</font></b></td><td><textarea
id='comment'cols="20"rows="5"name="Address"></textarea></td
></tr><br />
<tr><td><inputtype='submit'value='CheckForm'/></td></tr>
</table>
</form>
</body></html>
OUTPUT:
RESULT :
Thus developing client side scripts for validating webfrom controls using
DHTML has been verified.
EX.NO:4 INSTALLING &CONFIGURING TOMCAT-WEB SERVER
DATE:

AIM:
INSTALLING & CONFIGURING TOMCAT WEBSERVER
PROCEDURE:
Step1: Visit Apache Tomcat homepage with a Webbrowser,and click the "Download"link
under the "Tomcat 7.0.70Released" section.You will see the"Tomcat 7 Downloads"
page.
Step2: Click "32-bit Windows zip"link under"Binary Distributions"section.You will see the
download file save dialog box.(this supports jdk1.6 kit)
Step3: Use the "Savefile" option to save the download file
"apache-tomcat-7.0.70-windows-x86.zip"to a temporary folder.
Step 4: Unzip "apache-tomcat-7.0.70-windows-x86.zip" to file installation
folder“C:\ apache-tomcat-7.0.70”.
Step 5: Try to start Tomcat server by running the "startup" command in a
command linewindow:
C:\>cdapache-tomcat-7.0.70\bin
C:\>cdapache-tomcat-7.0.70\bin>startup
The CATAL IN A_HOME environment variable is not defined correctly This
environment variable is needed to run this program
Step6: To fix the missing environment variables , CATALINA_HOME,JAVA_HOME
&JRE_HOME,
● Click my computer->right click properties->Select Advance System Setting
● In this tab,Click Environment variable
● Click new in User variables for admin
● Enter variable name&Variable value
▪ CATALINA_HOME C:\apache-tomcat-7.0.70
▪ JAVA_HOME C:\Program Files\Java\
▪ JRE_HOME C:\Program Files\Java\jre7
Step7: Configuring Tomcat
Open “C:\apache-tomcat-7.0.70\conf”
Folder It consist of the following xmlfiles
Server.xml
Web.xml
Tomcat-
user.xml
Context.xml
Open web.xml in notepad&modify default-listings-false to true
Open server.xml & change port number 8080 to any other (8081) if any
application access the same port Open context.xml change reloadable attribute to
true on figuration procedure varies according to the version
Step 8: Try to start Tomcat server by running the "startup" command in a command
Line window:

OUTPUT:

RESULT:
Thus the Tomcat servers installed and configured successfully
EX.NO:5 A INVOKING SERVLET FROM HTML FORMS
DATE:

AIM:
To write a html program for invoking servlet using html.

ALGORITHM:

Step1: In html program,define the html,head and titletag.

Step2: Then the title is Student Information Form and close the title and headtag.

Step3: Define the body tag inside the body tag create form and
table simultaneously.
Step4: The table consists of following information Rollno,Studentname,
Address, Phone no and total marks.
Step5: In the servlet program,import the summary package and create a
ownservlet class extends with generic servlet.
Step6: In the service method defined to request and response.
Step7: Create the object and for print writer and getwriter() value.
Step8: The enumeration object get the servletrequest parameter.
Step9: Create objects for string method and it is displayed another
object value received get parameter of name received and
displayed the value received value.
PROGRAM:
//index.jsp
<html>
<head>
<title>Processing get requests with data</title>
</head>
<body>
<form action="Servlet3"method="get">
<b><p><label>Enter Your name Please!!
<br/>
<inputtype="text"name="firstname"/>
<inputtype="submit"value ="Submit"/>
</label></p></b>
</form>
</body>
</html>

//Servlet3.java
import
java.io.IOException;import
java.io.PrintWriter;
importjavax.servlet.ServletException;
import
javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse;
publicclassServlet3extends HttpServlet {
protectedvoiddoGet(HttpServletRequestrequest,
HttpServletResponseresponse)
throws ServletException, IOException {
StringfirstName=request.getParameter("firstname"
);response.setContentType("text/html");
PrintWriter out = response.getWriter();
//send XHTMLdocument to client
// start XHTML
documentout.println(
"<html>" );
// head section of
documentout.println(
"<head>" );
out.println("<title>Processing get requests with data</title>"
);out.println("</head>");
// body section of
documentout.println(
"<body>" );
out.println("<h1>Hello"+firstName+",<br/>"
);out.println("WelcometoServlets!</h1>");
out.println( "</body>" );
//endXHTMLdocument
out.println( "</html>" );
out.close();//closestreamtocompletethe page
}
public String
getServletInfo(){
return "Short
description";
}
}

OUTPUT:
RESULT:
Thus the invocation of servlet from HTML from has been
developed successfully.
EX.NO: 5 B SESSION TRACKING
DATE:

AIM:
To write a html program for invoking servlet using html.
ALGORITHM:

STEP 1: Remove a specific attribute You can delete the value associated with a specific key
by calling the public void remove Attribute (Stringname) function.
STEP 2: Delete your whole session. To delete an entire session, use the public void invalidate()
function.
STEP 3:Setting Session Timeout You may set the timeout for a session separately by calling
the public void set Max Inactive Interval(intinterval)function.
STEP 4:Log the user out On servers that support servlets 2.4, you may use the logout method
to log the client out of the Webserver and invalidate all of the users’sessions.
STEP 5:web.xml Configuration If you’re using Tomcat, you may set the session timeout in the
web.xml file, in addition to the ways listed above.
PROGRAM:

import java.io.*;
import java.util.*;
import javax.servlet.*;
importjavax.servlet.http.*;

//ExtendHttpServletclass
publicclassGfgSessionextendsHttpServlet{

public void doGet(HttpServletRequest request,


HttpServletResponse response)
throwsServletException,IOException
{

//Create a session object if it is already not


//created.
HttpSessionsession=request.getSession(true);

// Get session creation time.


Date createTime
=newDate(session.getCreationTime());

// Get last access time of this web page.


Date lastAccessTime
=newDate(session.getLastAccessedTime());

String title = "Welcome Back to geeksforgeeks";


Integer visitCount = new Integer(0);
String visitCountKey = new String("visitCount");
String userIDKey = new String("userID");
StringuserID=newString("GFG");
// Check if this is new comer on your web page.
if (session.isNew()) {
title = "Welcome to GeeksForGeeks";
session.setAttribute(userIDKey, userID);
}
else{
visitCount = (Integer)session.getAttribute(
visitCountKey);
visitCount = visitCount + 1;
userID
=(String)session.getAttribute(userIDKey);
}
session.setAttribute(visitCountKey,visitCount);

// Set response content type


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

StringdocType
="<!doctypehtmlpublic\"-//w3c//dtdhtml4.0"
+"transitional//en\">\n";

out.println(
docType+"<html>\n"
+"<head><title>"+title+"</title></head>\n"
+

"<bodybgcolor=\"#f0f0f0\">\n"
+"<h1align=\"center\">"+title+"</h1>\n"
+"<h2align=\"center\">Gfg Session Information</h2>\n"
+"<tableborder=\"1\"align=\"center\">\n"
+
"<trbgcolor=\"#949494\">\n"
+"<th>Session info</th><th>value</th>"
+"</tr>\n"
+

"<tr>\n"
+"<td>id</td>\n"
+"<td>"+session.getId()+"</td>"
+"</tr>\n"
+

"<tr>\n"
+"<td>Creation Time</td>\n"
+"<td>"+create Time+"</td>"
+"</tr>\n"
+

"<tr>\n"
+"<td>Time of Last Access</td>\n"
+"<td>"+last Access Time+"</td>"
+"</tr>\n"
+

"<tr>\n"
+"<td>UserID</td>\n"
+"<td>"+userID+"</td>"
+"</tr>\n"
+

"<tr>\n"
+"<td>Number of visits</td>\n"
+"<td>"+visit Count+"</td>"
+"</tr>\n"
+"</table>\n"
+"</body>"
+"</html>");
}
}
File:web.xml

 XML
<web-app>
<servlet>
<servlet-name>GfgSession</servlet-name>
<servlet-class>GfgSession</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>GfgSession</servlet-name>
<url-pattern>/GfgSession</url-pattern>
</servlet-mapping>
</web-app>

Compile the servlet Session Track describe above and addit to the web.xmlfile.When you
run http://localhost:8080/SessionTrackingGfg/GfgSession for the first time, you should get the
following result:

Output:
If we try to run the same servlet again,we will get the following result.

RESULT:
Thus the invocation of servlet in session tracking been developed successfully.
EX.NO : 6 A ONLINE EXAMINATION
DATE:

AIM:
To write a java servlet program to conduct online examination and to display student

mark list available in a database.

ALGORITHM:

Step1: Create a htmlfile with form tag.

Step2: The formtag action=”http://localhost:8080/example/servlet/exam”.

Step3: Create a two textbox(name&seatnumber).

Step4: The 5 question are defined into true or false model and close the all tags.

Step5: Import the necessary packages and declare class, classname in exam.

Step6: Declare the connection, statement and result set object.

Step7: Use the deposit() for check the connection in JDBC:ODBC driver.

Step8: The data are inserting into corresponding table.

Step9: The execute update () are update the database.

Step10: Display the table in after html file compilation.

PROGRAM:
//index.jsp
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">
<title>Welcome to Online Examination!!!!</title>
</head>
<body>
Welcome to Online Examination!!!!
<formaction="exam"method="get">
<label><p>Enter Your name Please!!<br/><input
type="text"name="name"/>
<br/>
<inputtype="submit"name="SUBMIT"/>
</p></label>
</form>
</body>
</html>
//exam.java
importjava.io.IOException;import
java.io.PrintWriter;
importjavax.servlet.ServletException;import
javax.servlet.annotation.WebServlet;import
javax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;import
javax.servlet.http.HttpServletResponse;public class
exam extends HttpServlet {
protectedvoiddoGet(HttpServletRequestrequest,
HttpServletResponseresponse)
throwsServletException,IOException{
response.setContentType("text/html");
PrintWriterout=response.getWriter();
String
name=request.getParameter("name");
out.println("<html>");
out.println("<head>");
out.println("<title>Online Examination</title>");
out.println("</head>");
out.println("<bodybgcolor=PINK>");
out.println("<h2 align=center>Online Examination</h2><hr>");
out.println("<h3 align=center> Welcome
Mr."+name+"</h3><hr>");out.println("<h4><u>Terms and
Conditions:</u></h4>"); out.println("<ul type=disc>");
out.println("<li>The Paper consists a set of fivequestions.</li>");
out.println("<li>Every question consists of two options.</li>");
out.println("<li>All must be answered</li></ul><hr>");
out.println("<center><h5><u>Your
Questions</u></h5></center>");out.println("<hr>");
out.println("<form method=get action=exam2>");
out.println("<p>1.Operating System is a ................ </p>");
out.println("<input type=radio name=q1
value=0>Hardware");out.println("<br>");
out.println("<input type=radio name=q1
value=1>Software");out.println("<hr>");
out.println("<p>2.Developer of C Languageis ................ </p>");
out.println("<br>");
out.println("<inputtype=radioname=q2value=0>Dennis
Richee");out.println("<br>");
out.println("<inputtype=radioname=q2value=1>James
Thompson");out.println("<hr>");
out.println("<p>3.Whichofthefollowingisamultitasking,multi
user,multiprocessing);
out.println("OS. ....... </p>");
out.println("<br>");
out.println("<inputtype=radioname=q3value=0>MS
DOS");out.println("<br>");
out.println("<inputtype=radioname=q3value=1>Windows
NT");out.println("<hr>");
out.println("<p>4.Father of Computersis ................. </p>");
out.println("<br>");
out.println("<inputtype=radioname=q4value=1>Charles
babbage");out.println("<br>");
out.println("<inputtype=radioname=q4value=0>Charles
Dickson");out.println("<hr>");
out.println("<p>5.What is the current generation of computers
?</p>");out.println("<br>");
out.println("<inputtype=radioname=q5
value=0>Fifth");out.println("<br>");
out.println("<inputtype=radioname=q5
value=1>Sixth");out.println("<hr>");
out.println("<input type=submit
value=Done>");out.println("</form>");
out.println("</body>");
out.println("</html>");
}
publicString getServletInfo()
{return"AServletofthe
user";
}
}
//exam2.java
import
java.io.IOException;import
java.io.PrintWriter;
import javax.servlet.ServletException;
importjavax.servlet.annotation.WebSer
vlet;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse;public
class exam2 extends HttpServlet {
protectedvoiddoGet(HttpServletRequestrequest,
HttpServletResponse
response)
throws ServletException,
IOException {int count=0,j;
response.setContentType("text/html
");PrintWriter
out=response.getWriter(); String
q1=request.getParameter("q1");
String
q2=request.getParameter("q2");
String
q3=request.getParameter("q3");
String
q4=request.getParameter("q4");
String
q5=request.getParameter("q5");
if(q1.equals("1"))
{
count=count+1;
}
if(q2.equals("1"))
{
count=count+1;
}
if(q3.equals("1"))
{
count=count+1;
}
if(q4.equals("1"))
{
count=count+1;
}
if(q5.equals("1"))
{
count=count+1;
}

out.println("<html>");
out.println("<head><title>Examination
Results</title></head>");out.println("<body>");
out.println("<h2align=center<Online Examination</h2><hr>");
out.println("<h3>Number of Questions answered
correctly:</h3>"+count);if(count>=3)
{
out.println("<hr><h3>Congrats!!!YouHave
Passed!!!</h3><hr>");
out.println("<h4><b>TryOther Tests!!</b></h4>");
}

else
{
out.println("<hr><h3>Sorry!!! You Have
Failed!!!</h3><hr>");out.println("<h4><b>Try
Again:</b></h4>");
}
out.println("</body>");
out.println("</html>");
}
publicStringgetServletInfo(){
return "A Servlet of the
User";
}
}

OUTPUT:
RESULT:
Thus the development of program in java to create three tire
application using servlet has been verified successfully.
EX.NO : 6 B DISPLAYING STUDENT MARK LIST USING JSP
DATE:

AIM:
To create a threetier application for displaying student marklist using JSP and database.

ALGORITHM:
1. Design the HTML page(stud.html)with the following
a) Create a form to get theinput (RegisterNumber)from the user.
b) Set the URL of the server(marklist.jsp) as the value of the action attribute.
c) Use submit button to invoke the server and send the form data to the server.
2. Create the JSP file with the following
a) Read the parameter value (RegisterNumber)from the form by using the method
getParameter().
b) Server retrieves the details from the database table with respect to the form input.
c) Server displays the marklist to the client as the response.

marklist.jsp:

<%@pagecontentType="text/html"language="java" import="java.sql.*"%>
<html>
<head>
<title>ThreeTier Application</title>
<style type="text/css">
body{color:blue;font-family:courier;text-align:center}
</style></head><body>
<h2>EXAMINATION RESULT</h2><hr/>
<%
String str=request.getParameter("regno");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connectioncon=DriverManager.getConnection("jdbc:odbc:markDS");
Statement stmt=con.createStatement();
ResultSetrs=stmt.executeQuery("SELECT*FROMmarkTabWHERErno="+str);
while(rs.next())
{
%>
RegisterNo:<%=rs.getObject(1)%><br/>
Name:<%=rs.getObject(2)%><br/>
<table border="1">
<th>SUBJECT</th><th>Mark</th>
<tr><td>Network Programming and Management</td><td><%=rs.getObject(3)%></td></tr>
<tr><td>Object Oriented Analysis and Design</td><td><%=rs.getObject(4)%></td></tr>
<tr><td>Cryptography and Network Security</td><td><%=rs.getObject(5)%></td></tr>
<tr><td>Embedded Systems</td><td><%=rs.getObject(6)%></td></tr>
<tr><td>Web Technology</td><td><%=rs.getObject(7)%></td></tr>
<tr><td>Software Requirement and Engineering</td><td><%=rs.getObject(8)%></td></tr>
</table>
<%}
%>
<br/>
<ahref="stud.html">Back</a>
</body></html>
stud.HTML:
<html>
<head>
<title>ThreeTier Application</title>
<style type="text/css">
body{color:blue;font-family:courier;text-align:center}
</style>
</head>
<body>
<h2>EXAMINATION RESULT</h2><hr/>
<formname="f1"method"GET"action="marklist.jsp">
Enter Your Reg.No:
<inputtype="text"name="regno"/><br/><br/>&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
<inputtype="submit"value="SUBMIT"/>
</form>
</body>
<html>

DATABASE
OUTPUTSCREENSHOTS

RESULT:
Thus the creation of a three-tier application for displaying student mark
list using JSP and database has been verified successfully.
EX.NO : 7 XML SCHEMA FOR STUDENT DETAILS
DATE:

AIM:
To write a program for implementing student information using XML&XSL.

ALGORITHM:

Step1:The XML document reference to the XSL document.


Step2:The create the student information in the student tagand insert the
same information about the student.
Step3:Close all opened tags.
Step4:In XSL document create a htmlfile include the student information in tableformat.
Step5:Close the necessary tags.
PROGRAM:
//student.xml
<?xmlversion="1.0"?>
<?xml-stylesheettype="text/css"href="student.css"?>
<!DOCTYPEstudentSYSTEM"student.dtd">
<students>
<student>
<sno>801041</sno>
<sname>S.Soundarapandian</sname>
<dob>05/081991</dob>
<address>Neyveli</address>
<m1>80</m1>
<m2>90</m2>
<m3>95</m3>
</student>
<student>
<sno>801049</sno>
<sname>R.Vadivelan</sname>
<dob>22/07/1990</dob>
<address>Pondicherry</address>
<m1>90</m1>
<m2>95</m2>
<m3>80</m3>
</student>
<student>
<sno>801037</sno>
<sname>R.Satheesh</sname>
<dob>21/01/1991</dob>
<address>Kanyakumari</address>
<m1>80</m1>
<m2>90</m2>
<m3>95</m3>
</student>
</students>
//student.css
Student{background.color:#aabbcc;width:100%;}Sno{
display:block; color:GREEN; font.size:25pt; } Sname {
display:block; color:BLACK; font.size:20pt; }Dob {
display:block; color:BLUE; font.size:15pt; } Address {
display:block; color:BLUE; font.size:15pt; }m1 {
display:block; color:BLUE; font.size:15pt; }
m2{display:block;color:BLUE;font.size:15pt;}m3{
display:block; color:BLUE; font.size:15pt;}
//student.dtd`
<?xmlversion="1.0"?>
<!ELEMENTstudents (student+)>
<!ELEMENTstudent(sno,sname,dob,address,m1,m2,m3)>
<!ELEMENTsno(#PCDATA)>
<!ELEMENTsname (#PCDATA)>
<!ELEMENTdob(#PCDATA)>
<!ELEMENTaddress (#PCDATA)>
<!ELEMENTm1(#PCDATA)>
<!ELEMENTm2(#PCDATA)>
<!ELEMENTm3(#PCDATA)>
OUTPUT:

RESULT:
Thus the creation of XSL document using Xml has been verified successfully

You might also like