0% found this document useful (0 votes)
32 views36 pages

WT Record

The document outlines a series of experiments related to web development, including image mapping in HTML, style sheets, and form validation using JavaScript. Each experiment includes an aim, procedure, program code, and results demonstrating successful execution. The experiments cover various aspects of web technology, such as creating interactive web pages and validating user input.

Uploaded by

csestaff24
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)
32 views36 pages

WT Record

The document outlines a series of experiments related to web development, including image mapping in HTML, style sheets, and form validation using JavaScript. Each experiment includes an aim, procedure, program code, and results demonstrating successful execution. The experiments cover various aspects of web technology, such as creating interactive web pages and validating user input.

Uploaded by

csestaff24
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/ 36

V

III

C.S.E

1
2
TABLE OF CONTENTS

S.NO. DATE EXPERIMENT TITLE MARKS/10 SIGN.

1 IMAGE MAPPING IN HTML

2 STYLE SHEETS

3 VALIDA TION USING JAVASCRIPT

4 INSTALLATION OFAPACHE TOMCAT

5a INVOKE SERVLETS FROM HTML FORMS

5b SESSION TRACKING USING HIDDEN FORM


FIELDS

6 ONLINE EXAM USING JSP

7 CREATION OF AN XML DOCUMENT

3
Ex. No:1 IMAGE MAPPING IN HTML
Date :

AIM:
To create a web page which includes a map and display the related information when a hot
spot is clicked in the map.

PROCEDURE:
1. Create a html file with map tag.
2. Set the source attribute of the img tag to the location of the image and also set the use map
attribute.
3. Specify an area with name, shape and href set to the appropriate values.
4. Repeat step 3 as many hot spots you want to put in the map.
5. Create html files for each and every hot spot the user will select.

PROGRAM:

ImageMap.html
<HTML>
<HEAD>
<TITLE>Image Map</TITLE> </HEAD>
<BODY>
<img src="india_map.jpg" usemap="#metroid" ismap="ismap" > <map name="metroid"
id="metroid">
<area href="TamilNadu.html" shape="circle" coords="208,606,50" title="TamilNadu"/>
<area href="Karnataka.html" shape="rect" coords = "130,531,164,535" title ="Karnataka" />
<area href="AndhraPradesh.html" shape="poly" coords =
"227,490,238,511,230,536,198,535,202,503" title ="Andhra Pradesh" />
<area href="Kerala.html" shape="rect" coords = "154,606,166,621" title ="Kerala" /> </map>
</BODY>
</HTML>
TamilNadu.html
<HTML><HEAD>
<TITLE>About Tamil Nadu</TITLE>
</HEAD>
<BODY>
<CENTER><H1>Tamil Nadu</H1></CENTER> <HR>
<UL>
<LI>Area : 1,30,058 Sq. Kms.</LI>
<LI>Capital : Chennai</LI>
<LI>Language : Tamil</LI>
<LI>Population : 6,21,10,839</LI> </UL><hr>
<a href='ImageMap.html'>India Map</a>
</BODY>
</HTML>

Karnataka.html
<HTML>
<HEAD>
<TITLE>About Karnataka</TITLE> </HEAD>
<BODY>
<CENTER><H1>Karnataka</H1></CENTER>
<HR>

4
<UL>
<LI>Area : 1,91,791 Sq. Kms</LI>
<LI>Capital : Bangalore</LI>
<LI>Language : Kannada</LI>
<LI>Population : 5,27,33,958</LI>
</UL>
<hr>
<a href='ImageMap.html'>India Map</a>
</BODY>
</HTML>

AndhraPradesh.html
<HTML>
<HEAD>
<TITLE>About Andhra Pradesh</TITLE> </HEAD>
<BODY>
<CENTER><H1>Andhra Pradesh</H1></CENTER> <HR>
<UL>
<LI>Area : 2,75,068 Sq. Kms</LI>
<LI>Capital : Hyderabad</LI>
<LI>Language : Telugu</LI>
<LI>Population : 7,57,27,541</LI>
</UL>
<hr>
<a href='ImageMap.html'>India Map</a>
</BODY>
</HTML>

Kerala.html
<HTML>
<HEAD>
<TITLE>About Kerala</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>Kerala</H1></CENTER>
<HR>
<UL>
<LI>Area : 38,863 Sq. Kms.</LI>
<LI>Capital : Thiruvananthapuram</LI>
<LI>Language : Malayalam</LI>
<LI>Population : 3,18,38,619</LI>
</UL>
<hr>
<a href='ImageMap.html'>India Map</a>
</BODY></HTML>

5
OUTPUT:

RESULT:
Thus the creation of a web page which includes a map and display the related in-formation
when a hot spot is clicked in the map was executed successfully.

6
Ex. No: 2 STYLE SHEETS
Date :

AIM:
To create a web page that displays college information using various style sheet

PROCEDURE:
1. Create a web page with frame sets consisting two frames
2. In the first frame include the links
3. In the second frame set display the web page of the link
4. Create a external style sheets
5. Create a embedded style sheets
6. Create a inline and internal style sheets and make it link to the external style sheets

PROGRAM:

INTERNAL CSS:
• Create a html program with<style> tag.
• Inside the<style>tag specify the format
required for that webpage.
EXTERNAL CSS:
1. Open notepad,type the needed css in it and save it.
2. Css file in the HTMLusing the tag<link>
3. Run the program.
4. Display the results
5. Stop the program

HTML CODE: College.html


<html>
<head><h1 class="vid"><center>GKM GROUP OF INSTITUTIONS</center></h1>
<title>
</title>
<link rel="stylesheet" href="external.css" media="all" type="text/css">
<style type="text/css">
.vid{font-family:verdana;font-style:italic;color:red;text-align:center}
.ani{font-family:tahoma;font-style:italic;font-size:20;text-align:center;}
font{font-family:georgia;color:blue;font-size:20}
ul{list-style-type:circle}
</style>
</head>
<body bgcolor="cyan">
<ol style="list-style-type:lower-alpha">
<b class="vid">GKM EDUCATIONS</b><br><br><br>
<li>GKM COLLEGE OF ENGINEERING & TECHNOLOGY
<li>GKM POLYTECHNIC COLLEGE
<li>GKM VIDYASHRAM
</ol>
<p style="font-size:20pt;color:purple">GKM COLLEGES</p>
<img src="GKM.jpg"/>
7
<p class="ani">Approved by AICTE and Affiliated to AnnaUniversity.<br><br></p>
<h2 class="vid">About Us</h2>
<br>
<font><strong>GKM COLLEGE OF ENGINEERING & TECHNOLOGY, </strong>
brain child of our Honorable Chairman bloomed on 1998 intended to provide the world class
technical education to conquer tomorrow's technology at global level with human values, so
as to make our student community succeeds in life. The institution has developed the state-of-
art infrastructure within the short span of time with dedicated and determined staff members.
</p> <img src="GKM1.jpg"/>
<p>GKM POLYTECHNIC COLLEGE is committed to be a leader in innovative
work force development and a world class learning venue for the ever-changing needs of
Business and Industry.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font><br>
<br>
<font>
<h2 class="vid"> ACADEMICS OVERVIEW </h2>
<h2 class="vid"><strong>UG B.E/B.TECH PROGRAM</strong></h2>
<ul>
<li>Computer Science and Engineering</li>
<li>Electronics and Communication Engineering</li>
<li>Mechanical Engineering</li>
<li>Information Technology</li>
<li>Electrical and Electronics Engineering </li>
</ul>
</font>

<br>
<font>
<h3 class="vid"><strong>PG PROGRAMME M.E/MBA</strong></h3>
<div ><br /></div>
<ul>
<li>MBA (Master of Business Administration)</li>
<li>M.E Computer Science and Engineering</li>
<li>M.E Embedded System Technologies</li>
<li>M.E Bio Medical Engineering</li>
<li>M.E Software Engineering </li>
</ul>
</font>
<td><strong>MBA (Master of Business Administration)</strong></td>
<table width="100%" border="5">
<tr>
<td>Year of Establishment:</td>
<td><strong>2009</strong></td>
</tr>
<tr>
<td>Membership in:</td>
<td><strong>MMA</strong></td>
</tr>
<tr>
<td>Courses offered:</td>
<td ><strong>MBA
(Intake 60)</strong></td>
</tr>
<tr>
<td>Collaborations:</td> 8
<td ><strong>MOU with MSE</strong></td>
</tr>
</table>
<h4 class="vid">GKM ACADEMICS AND PLACEMENTS</h4>
<table width="100%" cellspacing="2"
cellpadding="2" border="5">
<tr>
<th>COURSE NAME</th>
<th>YEAR</th>
<th>PASS PERCENTAGE</th>
<th>PLACEMENT</th>
</tr>
<tr>
<td align="center">BE-CSE</td>
<td align="center">2020</td>
<td align="center">79</td>
<td align="center">60% PLACED</td>
</tr>
<tr>
<td align="center">BE-CSE</td>
<td align="center">2021</td>
<td align="center">65</td>
<td align="center">50% PLACED</td>
</tr>
<tr>
<td align="center">BE-CSE</td>
<td align="center">2022</td>
<td align="center">98</td>
<td align="center">90% PLACED</td>
</tr>
</table>
OUTPUT:

RESULT:
Thus the creation of a web page that displays college information using various style sheet
was successfully executed and verified.
9
Ex. No: 3 FORM VALIDATION USING JAVA SCRIPT
Date:

AIM:
To Validate the Registration, user login, user profile and payment by credit card pages
using JavaScript.
Algorithm:
1.Start the program.
2.Write proper user name and password and validate that field.
3. JavaScript provides a way to validate form's data on the client's computer before sending it to the
web server. Form validation generally performs two functions.
• Basic Validation − First of all, the form must be checked to make sure all the mandatory fields are
filled in. It would require just a loop through each field in the form and check for data.
• Data Format Validation − Secondly, the data that is entered must be checked for correct form and
value. Your code must include appropriate logic to test correctness of data.
PROCEDURE:
1. Static web pages is developed with following pages.
User Login, User profile and Registration
Payment by credit card
2. Each input box in webpage is validated using java script code using <script> tag in html
file.
3. Designed output is displayed.

I-REGISTRATION FORM:

javascript-form-validation.html:

<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>JavaScript Form Validation using a sample registration form</title>
<meta name="keywords" content="example, JavaScript Form Validation, Sample registration
form" />
<meta name="description" content="This document is an example of JavaScript Form
Validation using a sample registration form. " />
<link rel='stylesheet' href='js-form-validation.css' type='text/css' />
<script src="sample-registration-form-validation.js"></script>
</head>
<body onload="document.registration.userid.focus();">
<h1>Registration Form</h1>
<p>Use tab keys to move from one input field to the next.</p>
<form name='registration' onSubmit="return formValidation();">
<ul>
<li><label for="userid">User id:</label></li>
<li><input type="text" name="userid" size="12" /></li>
<li><label for="passid">Password:</label></li>
<li><input type="password" name="passid" size="12" /></li>
<li><label for="username">Name:</label></li>

10
<li><input type="text" name="username" size="50" /></li>
<li><label for="address">Address:</label></li>
<li><input type="text" name="address" size="50" /></li>
<li><label for="country">Country:</label></li>
<li><select name="country">
<option selected="" value="Default">(Please select a country)</option>
<option value="AF">Australia</option>
<option value="AL">Canada</option>
<option value="DZ">India</option>
<option value="AS">Russia</option>
<option value="AD">USA</option>
</select></li>
<li><label for="zip">ZIP Code:</label></li>
<li><input type="text" name="zip" /></li>
<li><label for="email">Email:</label></li>
<li><input type="text" name="email" size="50" /></li>
<li><label id="gender">Sex:</label></li>
<li><input type="radio" name="msex" value="Male" /><span>Male</span></li>
<li><input type="radio" name="fsex" value="Female" /><span>Female</span></li>
<li><label for="desc">About:</label></li>
<li><textarea name="desc" id="desc"></textarea></li>
<li><input type="submit" name="submit" value="Submit" /></li>
</ul>
</form>
</body>
</html>

js-form-validation.css

h1 {
margin-left: 70px;
}
form li {
list-style: none;
margin-bottom: 5px;
}
form ul li label{
float: left;
clear: left;
width: 100px;
text-align: right;
margin-right: 10px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:14px;
}
form ul li input, select, span {
float: left;
margin-bottom: 10px;
}

11
form textarea {
float: left;
width: 350px;
height: 150px;
}
[type="submit"] {
clear: left;
margin: 20px 0 0 230px;
font-size:18px
}
p{
margin-left: 70px;
font-weight: bold;
}

sample-registration-form-validation.js

function formValidation()
{
var uid = document.registration.userid;
var passid = document.registration.passid;
var uname = document.registration.username;
var uadd = document.registration.address;
var ucountry = document.registration.country;
var uzip = document.registration.zip;
var uemail = document.registration.email;
var umsex = document.registration.msex;
var ufsex = document.registration.fsex; if(userid_validation(uid,5,12))
{
if(passid_validation(passid,7,12))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(countryselect(ucountry))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
if(validsex(umsex,ufsex))
{
}}}}}}}}
return false;
} function userid_validation(uid,mx,my)
{
var uid_len = uid.value.length;
if (uid_len == 0 || uid_len >= my || uid_len < mx)

12
{
alert("User Id should not be empty / length be between "+mx+" to "+my);
uid.focus();
return false;
}
return true;
}
function passid_validation(passid,mx,my)
{
var passid_len = passid.value.length;
if (passid_len == 0 ||passid_len >= my || passid_len < mx)
{
alert("Password should not be empty / length be between "+mx+" to "+my);
passid.focus();
return false;
}
return true;
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if(uname.value.match(letters))
{
return true;
}
else
{
alert('Username must have alphabet characters only');
uname.focus();
return false;
}
}
function alphanumeric(uadd)
{
var letters = /^[0-9a-zA-Z]+$/;
if(uadd.value.match(letters))
{
return true;
}
else
{
alert('User address must have alphanumeric characters only');
uadd.focus();
return false;
}}
function countryselect(ucountry)
{
if(ucountry.value == "Default")
{

13
alert('Select your country from the list');
ucountry.focus();
return false;
}
else
{
return true;
}}
function allnumeric(uzip)
{
var numbers = /^[0-9]+$/;
if(uzip.value.match(numbers))
{
return true;
}
else
{
alert('ZIP code must have numeric characters only');
uzip.focus();
return false;
}}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
return true;
}
else
{
alert("You have entered an invalid email address!");
return false;
}
} function validsex(umsex,ufsex)
{
x=0;

if(umsex.checked)
{
x++;
}
if(ufsex.checked)
{
x++;
}

if (x==2)
{
alert('Both Male/Female are checked');

14
ufsex.checked=false
umsex.checked=false
umsex.focus();
return false;
}

if(x==0)
{
alert('Select Male/Female');
umsex.focus();
return false;
}
else
{
alert('Form Succesfully Submitted');
window.location.href="payment.html";
return true;
}}

II PAYMENT FORM

payment.html

<!DOCTYPE>
<html>
<head>
<title>Payment Form</title>
</head>
<body bgcolor="lightblue">
<form>
<h1>Payment Form</h1>
<p>Required field are followed by*</p>
<h2>Contact information</h2>
<p>Name:*<input type="text" name="name" required=""></p>
<fieldset>
<legend>Gender*</legend>
<p>
Male <input type="radio" name="gender" id="Male" required="">
Female <input type="radio" name="gender" id="Female" required="">
</p>
</fieldset>
<p>Address: <textarea name="address" id="address" rows="6"
cols="80"></textarea></p>
<p>Email:* <input type="email" name="email" id="email" value="" required="" /></p>
<p>Pincode:* <input type="number" name="pincode" id="pincode" value="" required=""
/></p>
<hr>
<h2>Payment Information</h2>
<p>Card Type:*

15
<select name="card_type" id="card_type" required="">
<option value="">---selecr a Card type--</option>
<option value="visa">Visa</option>
<option value="rupy">Rupay</option>
<option value="master card">Master Card</option>
</select>
</p>
<p>
Card Number *<input type="number" name="card Number" id="Card Number"
required="">
</p>
<p>
Expiration Date:* <input type="date" name="exp_date" id="exp_date" required="">
</p>
<p>
CVV * <input type="password" name="CVV" id="CVV" required="">
</p>
<input type="submit" name="" id="" value="Pay Now" />

</form>
</body>
</html>

styles.css
body{

padding: 25px;

.title {

color: #5C6AC4;

script.js

function showTime() {

document.getElementById('currentTime').innerHTML = new Date().toUTCString();

showTime();

setInterval(function () {

showTime();

}, 1000);

16
Output:

RESULT:

Thus, the form validation using java Script executed successfully.

17
Ex.no:4 Installation Apache tomcat Web Server
Date:

Aim:
To learn to install the Apache Tomcat server on Windows.
Steps:

Step 1: Download Tomcat for Window.


1. Browse to the official Apache Tomcat website. Locate the Download section and click the latest Tomcat
version available. At the time of writing this article, the latest Tomcat version was version 10.

2. On the Download page, scroll down and locate the Binary Distributions area. In the Core list,
depending on the installation type you prefer, click the download link for the Windows Service Installer or
the 32bit/64bit Windows zip file.

18
Step 2: Install Tomcat

Follow the steps below to install Tomcat using the Windows Service Installer.

1. Open the downloaded Windows Service Installer file to start the installation process.

2. In the Tomcat Setup welcome screen, click Next to proceed.

3. Read the License Agreement and if you agree to the terms, click I Agree to proceed to the next step.

19
4. In the Tomcat component selection screen, choose Full in the dropdown menu to ensure the wizard
installs the Tomcat Host Manager and Servlet and JSP examples web applications. Alternatively, keep the
default Normal installation type and click Next.

5. The next step configures the Tomcat server. For instance, enter the Administrator login credentials or
choose a different connection port. When finished, click Next to proceed to the next step.

6. The next step requires you to enter the full path to the JRE directory on your system. The wizard
auto-completes this if you have previously set up the Java environment variables. Click Next to
proceed to the next step.

20
7. Choose the Tomcat server install location or keep the default one and click Install.

8. Check the Run Apache Tomcat box to start the service after the installation finishes. Optionally, check
the Show Readme box to see the Readme file. To complete the installation, click Finish.

21
9. A popup window appears that starts the Tomcat service. After the process completes, the window
closes automatically. The Apache Tomcat web server is now successfully installed .

Result:

This guide showed how to install the Apache Tomcat web server on Windows.

22
Ex.No:5a INVOKING SERVLETS FROM HTMLFORM
Date:

AIM:
To write a java program to invoke servlets from HTML form.

PROCEDURE:
client.html:
(1) Create a web page using HTML form that contains the fields such as text, password and one
submit button.
(2) Set the URL of the server as the value of form’s action attribute.
(3) Run the HTML program.
(4) Submit the form data to the server.

server.java:
(1) Define the class server that extends the property of the class HttpServlet
(2) Handle the request from the client by using the method service() of HttpServlet class.
(3) Get the parameter names from the HTML form by using the method getParameterNames().
(4) Get the parameter values from the HTML forms by using the method getParameter().
(5) Send the response to the client by using the method of PrintWriter class.

PROGRAM:

MySrv.java:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySrv extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");

//Getting HTML parameters from Servlet

String username=request.getParameter("uname");
String password=request.getParameter("pwd");
if((username.equals("user")) && (password.equals("pswd")))
{
out.println(" <h1> Welcome to "+username);
}
else
{

23
out.println(" <h1> Registration success ");
out.println(" <a href='./index.html'> Click for Home page </a>");
}
out.println(" </BODY>");
out.println("</HTML>");
out.close();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost( request,response);
}
}

Registration.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY bgcolor='#e600e6'>
<form action='./MySrv' method="post">
<center> <h1> <u> Login Page </u></h1>
<h2> Username : <input type="text" name="uname"/>
Password : <input type="password" name="pwd"/>
<input type="submit" value="click me"/>
</center>
</form>
</body>
</HTML>

web.xml:
<web-app>
<servlet>
<servlet-name>MySrv</servlet-name>
<servlet-class>MySrv</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MySrv</servlet-name>
<url-pattern>/MySrv</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

24
OUTPUT:

RESULT:
Thus the java program to invoke servlets from HTML form has been executed successfully.

25
Ex.No:5b SESSION TRACKING USING HIDDEN FORM
Date:

AIM:
To write a Java Program for Session Tracking Using Hidden Form Fields. This servlet
demonstrates session tracking using hidden form fields by displaying the shopping cart for a
bookworm. Note that, if you try this servlet, the buttons at the bottom of the page it generates don't
take you anywhere real.

PROCEDURE:
1. Create a web page using HTML form that contains the fields such as text, password and one
submit button.
2. Set the URL of the server as the value of form’s action attribute.
3. Ask if the user wants to add more items or check out.
4. Include the current items as hidden fields so they'll be passed on and submit to self.

PROGRAM:
register.html:

<html>
<body bgcolor = "cyan">
<center>
<h1>WELCOME TO REGISTRATION PAGE</h1>
<form action="./registerone" METHOD="post">
Name: <input type="text" name = "name"><br><br>
Password: <input type="password" name="password"><br><br>
PROFESSION:
<select name="profession">
<option value="engineer">ENGINEER</option>
<option value="teacher">TEACHER</option>
<option value="businessman">BUSINESSMAN</option>
</select><br><br>
<input type="submit" value="REGISTER">
</form>
</center>
</body>
</html>

web.xml
<web-app>
<welcome-file-list>
<welcome-file>register.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>RegistrationServletOne</servlet-name>
<servlet-class>RegistrationServletOne</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegistrationServletOne</servlet-name>
<url-pattern>/registerone</url-pattern>
</servlet-mapping>
<servlet>

26
<servlet-name>RegistrationServletTwo</servlet-name>
<servlet-class>RegistrationServletTwo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegistrationServletTwo</servlet-name>
<url-pattern>/registertwo</url-pattern>
</servlet-mapping>
</web-app>

RegistrationServletOne.java:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RegistrationServletOne extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String name = request.getParameter("name");
String password = request.getParameter("password");
String profession = request.getParameter("profession");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body bgcolor = wheat>");
out.println("<center>");
out.println("<h1>COMPLETE THE REGISTRATION</h1>");
out.println("<form action = ./registertwo method = post");
out.println("<input type = hidden name = name value =" + name + ">");
out.println("<input type = hidden name = password value =" + password + ">");
out.println("<input type = hidden name = profession value =" + profession + ">");
out.println("EMAIL ID:<input type =text name = email><br><br>");
out.println("PHONE NO:<input type =text name = cell><br><br>");
out.println("<input type =submit value=registernow>");
out.println("</center>");
out.println("</body></html>");
out.close();
}
}

RegistrationServletTwo.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RegistrationServletTwo extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException

27
{
String name = request.getParameter("name");
String password = request.getParameter("password");
String profession = request.getParameter("profession");
String email = request.getParameter("email");
String cell = request.getParameter("cell");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body bgcolor = wheat>");
out.println("<center>");
out.println("<h1>REGISTRATION SUCCESSFUL..........</h1>");
out.println("</center>");
out.println("</body></html>");
out.close();
}
Output:

28
RESULT:
Thus the Java program for Session Tracking using hidden form fields has been executed
successfully.

RESULT:
Thus the Java program for Session Tracking using hidden form fields has been executed successfully

29
Expt.no: 6 ONLINE EXAMINATION USING JSP
Date:

AIM:

To create a three tier application for conducting online examination using JSP and database.

ALGORITHM:

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

a) Create a form to get the input from the user.

b) Use radio buttons to make various options for the questions.

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

d) 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 input from the client.

b) Retrieve the answers from the database.

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

d) For each correct answer increment the mark by 5.

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

PROGRAM:

ExamClient.html

<html>

<head>

<title>Online Exam Client</title>

<style type="text/css">

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

</style>

</head>

<body>

<h2 style="text-align:center">ONLINE EXAMINATION</h2>

<h3>Answer the following questions (5 marks for each correct answer)</h3>

<hr/>

<form name="examForm" method="post" action="ExamServer.jsp">

30
1.Who is called as the father of computer?<br/>

<input type="radio" name="ans1" value="Sachin">Sachin

<input type="radio" name="ans1" value="Stuart">Stuart

<input type="radio" name="ans1" value="Charles Babbage">Charles Babbage

<input type="radio" name="ans1" value="Napier">Napier

<br/><br/>

2.C++ was developed by?<br/>

<input type="radio" name="ans2" value="Dennis Ritchie">Dennis Ritchie

<input type="radio" name="ans2" value="None">None

<input type="radio" name="ans2" value="David Ritchie">David Ritchie

<input type="radio" name="ans2" value="John">John

<br/><br/>

3.C was developed by?<br/>

<input type="radio" name="ans3" value="Dennis Ritchie">Dennis Ritchie

<input type="radio" name="ans3" value="Stroustrup">Stroustrup

<input type="radio" name="ans3" value="David Ritchie">David Ritchie

<input type="radio" name="ans3" value="Charles Babbage">Charles Babbage

<br/><br/>

<input type="submit" value="Check Your Result"/>

</form>

</body>

</html>

ExamServer.jsp

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

<html>

<head>

<title>Online Exam Server</title>

<style type="text/css">

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

</style>

</head>

<body>

31
<h2 style="text-align:center">ONLINE EXAMINATION</h2>

<p>

<a href="ExamClient.html">Back To Main Page</a>

</p>

<hr/>

<%

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

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

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

int mark=0;

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

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

Statement stmt=con.createStatement();

ResultSet rs=stmt.executeQuery("SELECT * FROM examTab");

int 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;

32
if(i==3)

String dbans3=rs.getString(1);

if(str3.equals(dbans3))

mark=mark+5;

i++;

if(mark>=10)

out.println("<h4>Your Mark Is : "+mark+"</h4>");

out.println("<h3>Congratulations....! You Are Eligible For The Next Round...</h3>");

else

out.println("<h4>Your Mark is : "+mark+"</h4>");

out.println("<h3>Sorry....!! You Are Not Eligible For The Next Round...</h3>");

%>

</form>

</body>

</html>

33
Sample Output:

Result:
Thus to create a three tier application for conducting online examination using JSP and
database and to display student mark list available in a database was successfully executed and
verified.

34
Ex. No:7 CREATION OF XML DOCUMENT
Date :

AIM:
To create and save an XML document at the server, which contain some users information.
To develop Java Program takes user id as an input and returns the user details by taking the user
information from the XML document.

PROCEDURE:
1. Save Students information in the XML file on the specific location.
2. Create and Establish the server connection between html file and XML file in the host
3. Get the user ID as input
4. Display the user’s information.

PROGRAM :

xm.xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="student.xsl"?>
<class>
<student rollno="54321">
<firstname>Smith</firstname>
<lastname>S</lastname>
<nickname>smith</nickname>
<marks>85</marks>
</student >
<student rollno="54322">
<firstname>Marsh</firstname>
<lastname>M</lastname>
<nickname>marsh</nickname>
<marks>90</marks>
</student >
<student rollno="54323 ">
<firstname>John</firstname>
<lastname>Doe</lastname>
<nickname>John</nickname >
<marks>90</marks>
</student>
</class>

35
student.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1 .0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transf orm">
<xsl:template match="/ ">
<html>
<body>
<h2>students</h2>
<table border=" 1 ">
<tr bgcolor= "#9acd32 ">
<th>Roll No</th>
<th>First Name</th>
<th>Last Name</th>
<th>Nick Name</th>
<th>Marks</th>
</tr>
<xsl :for-each select= "class/student ">
<tr>
<td> <xsl :value -of select= "rollno "/></td>
<td><xsl:value-of select= "firstname "/></td>
<td><xsl :value-of select= "lastname "/></td>
<td><xsl :value-of select= "nickname "/></td>
<td><xsl :value-of select= "marks "/></td>
</tr>ÿ</xsl:for -each>
</table>
</body>
</html>
</xsl :template>
</xsl :stylesheet>

OUTPUT:

36

You might also like