CCS375 Web Technologies Final Lab Manual
CCS375 Web Technologies Final Lab Manual
COLLEGE OF ENGINEERING
AND TECHNOLOGY
TIRUPUR-641665
(AN ISO 9001:2015 CERTIFIED
INSTITUTION}
BONAFIDE CERTIFICATE
Register Number……………………………………………..
…………………………………………………………………………………………………… of B.E.
Computer Science And Engineering branch for the 06 semester during the academic
Signature of Signature of
1
INDEX
INSTALLATION OF APACHE
4 TOMCAT WEB SERVER
i. INVOKING SERVLETS
5 FROM HTML FORM
2
EX:NO:1
To create a web page which includes a map and display the related information when a
hot spot is clicked in the map.
PROBLEM DESCRIPTION:
Image mapping:
• An image map is an image with clickable areas.
• In image mapping an image is specified with certain set of coordinates inside the image
which act as hyperlink areas to different destinations.
Elements required:
• The HTML<map>tag defines an image map.
• Three basic html elements required for creating snapped image.
► Map :Used to create map of the image with clickable areas
► 1mg:Usedtodisplayimage
► Area:Used with in the map for defining clickable areas
PROCEDURE:
3
CODING:
Imagemap.html
<!DOCTYPEhtml>
<html>
<head>
<Title>ImageMapping</Title>
<h3><center>MappinganImage</center></h3>
<body>
<p>ClickonContinentstoknowaboutthem</p>
<imgsrc="D:\world-map-151576_960_720.png"width="960"height= "492" alt = "World
Map"usemap = "#worldmap">
<mapname="worldmap">
<area shape="rect" coords="184, 36, 272, 158" alt="north america"
href="https://en.wikipedia.org/wiki/North_America">
<areashape="rect"coords="282,215,354,367"alt="southamerica"href="https://en.wikipedia.or
g/wiki/South_America">
<area shape="rect" coords="506, 151, 570, 333" alt="africa"
href="https://en.wikipedia.org/wiki/Africa">
<area shape="rect" coords="618, 42, 791, 162" alt="asia"
href="https://en.wikipedia.org/wiki/Asia">
<area shape="rect" coords="509, 44, 593, 110" alt="europe"
href="https://en.wikipedia.org/wiki/Europe">
<area shape="rect" coords="786, 288, 862, 341" alt="australia"
href="https://en.wikipedia.org/wiki/Australia_(continent)">
<area shape="rect" coords="249, 463, 760, 488" alt="antartica"
href="https://en.wikipedia.org/wiki/Antarctica">
</map>
</body>
</html>
4
OUTPUT:
5
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the given experiment to create a web page which includes a map and display
the Related information when a hotspots is clicked in the map is successfully verified and
executed.
6
EX.NO:2
DATE:
TYPES OF CASCADING STYLE SHEET
AIM:
To create a web page for our college which includes Cascading style sheet,
Embedded style sheet and Inline Style sheet.
PROBLEM DESCRIPTION:
Web Page:
• A webpage is a document written in Hyper Text Markup Language and can be viewed
on any web browser.
• A web page is a structured document that primarily consists of hypertext, text with
hyperlinks.
• It is contained with in the web server , which can be accessed by entering the URL for
that web page , and once it is loaded , it appears on the user's web browser.
Elements required:
• The<style>tag is used to define style information(CSS).
• Inside the<style>element specify how HTML elements should render in a browser.
• CSS can be added to HTML documents in 3ways:
➢ Inline-by using the style attribute inside HTML elements.
➢ Internal-by using a<style>element in the<head>section.
➢ External-by using a<link>to link to an external CSS file.
PROCEDURE:
1. Create a CSS file with Styles.
2. Create a html file with college information.
3. Run the HTML file
7
CODING:
index.html
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>2ndProgram</title>
<!--ExternalStyleSheet-->
<linkrel="stylesheet"href="./style.css">
<!--InternalStyleSheet-->
<style>
*{
padding:0px; margin:
0px;
}
nav{
display:flex;
background-color: aqua; justify-
content:space-between; padding: 5px;
}
.nav-items {
display:inline-flex;
height:3rem;
width:80px;
align-items: center; justify-
content:center; border-
radius: 10px;
}
</style>
</head>
8
<body>
<nav>
<!--InlineStyles-->
<divclass="nav-container"style="display:flex;align-items:center;">
<img src="./logo.png" alt="College logo" style="height:3rem;
margin-right : 10px; width:4rem;margin-left: 1rem;">
<h2>JaiShriramEngineeringCollege</h2>
</div>
<divclass="nav-container">
<ul>
<li class="nav-items" style="background-color: wheat; color:
black"> Home</li>
<liclass="nav-items">Branch</li>
<liclass="nav-items">Course</li>
<liclass="nav-items">Profile</li>
</ul>
</div>
</nav>
<divid="body-content">
<div id="sidebar">
<buttonclass="side-items">StudentsList</button><br>
<buttonclass="side-items">Placement</button><br>
<buttonclass="side-items">CollegeProfile</button><br>
<buttonclass="side-items">Companies</button><br>
<button class="side-items">About Barani Hydraulics India Private
Limited</button>
</div>
<div id="content">
<h4>To provide value added education in engineering, technology and
management by elevating the student community with state-of-the art infrastructure
facilities, interactive teaching, learning techniques and hands-on training through our own
industry support. Jai Shriram Engineering College was endowed by Shenthil Velevan Trust
in the year 2009withamottoofequippingandimplantingtheseedofhighereducation
9
blended with communal harmony to the rural community in and around the Textile City.
JSREC reinforces to impart knowledge which are innards of a meaningful life.</h4>
</div>
</div>
</body>
</html>
style.css
#body-content{ display:flex;
}
#sidebar {
padding:10px;
background-color:rgb(0,217,255);
height:88vh;
}
.side-items:hover{
background-color:rgb(0,255,255);
}
.side-items{
border-radius:10px;
height:4rem; width:18rem;
background-color:transparent; border: 1px
solid white;
margin-top:3px;
font-size: 17px;
}
#content{ width:100%;
background-color:rgb(231,231,247); display: flex;
10
align-items: center; justify-
content:center;
padding:50px;
text-align:center;
font-size: 25px;
}
OUTPUT:
11
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the given to create a web page for our collage which includes cascading
style sheet , embedded style sheet and inline style sheet is successfully verified and
executed.
12
EX.NO:3
CLIENT-SIDE SCRIPTS FOR VALIDATING WEB FORM
DATE: CONTROLS USING DHTML
AIM:
PROBLEM DESCRIPTION:
Forms:
• Forms are used on web pages for the user to enter their required details that further send to the
server for processing.
• A form is also known as a web form or HTML form.
Java Script:
• Java Script makes HTML pages more dynamic and interactive.
• Java Script is a scripting language that enables you to create dynamically updating content
,control multi media ,animate images ,etc.
• Java Script is a text-based programming language that can be used both server-side and client-
side in our net applications.
• JavaScriptisusedfordevelopingwebpageswithmoreinteractiveanduser-friendly.
Elements required:
• <form>
• <script>
• <label>
• <input>
• <div>
<style>
13
PROCEDURE:
1. Static web pages of an online Book store is developed with following pages.
Homepage
Registration and user Login User
profile page
Books catalogue Payment by
credit card
2. Each input box in web page is validated using java script code using
<script>tag in html file.
3. Designed output is displayed.
CODING:
<html>
<head>
<title>ASimpleFormwithJavaScriptValidation</title>
<scripttype="text/javascript">
<!--
functionvalidate_form()
{
valid=true;
if(document.contact_form.contact_name.value=="")
{
alert("Pleasefillinthe'YourName'box."); valid = false;
}
if(document.contact_form.contact_name.value!="")
{
alert("Succesfull");
valid = false;
}
returnvalid;
}
//-->
</script>
</head>
<bodybgcolor="#FFFFFF">
<formname="contact_form"method="post"onSubmit="return validate_form ( );">
PleaseEnterYour Name
<p>YourName:<inputtype="text"name="contact_name"></p>
<p><inputtype="submit"name="send"value="SendDetails"></p>
</form>
14
</body>
</html>
OUTPUT:
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the given To validate Web Form Controls using DHTML is successfully verified
and executed.
15
EX.NO:4
AIM:
PROBLEM DESCRIPTION:
Apache Tomcat:
• Apache Tomcat is an open-source web server and servlet container for Java code.
• Tomcat executes programs written in the Java programming language, and it implements
many Java EE specifications ,including Jakarta Servlet ,Jakarta Server Pages, and others.
Prerequisites:
• Java JRE installed and configured
• Administrator privileges
PROCEDURE:
16
Step2:Install Tomcat
17
Install Tomcat via the Windows Service Installer for an automated and wizard-guided
experience.
The service installer installs the Tomcat service and runs it automatically when the system
boots.
For a portable experience, install Tomcat using the zip file and avoid installing the service.
Easily uninstall Tomcat when it is no longer needed by deleting the Tomcat directory,
or move it around when necessary.
Method 1: Install Tomcat Using the Windows Service Installer 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.
18
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.
19
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.
7. Choose the Tomcat server install location or keep the default one and click Install.
20
8. ChecktheRunApacheTomcatboxtostarttheserviceafterthe installation finishes.
Optionally,checktheShowReadmeboxtoseetheReadmefile.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
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the given to install apache tomcat web server is successfully verified and
executed.
22
EX.NO:5
AIM:
To write a java program to invoke servlets from HTML form.
PROBLEM DESCRIPTION:
Java:
• Java is a widely used programming language for coding web applications.
• Java is a multi-platform ,object oriented and network centric language that can be used
as a platform in itself.
Servlet:
• Servlet is an application that is running on a server.
• Servlet is a Java programming language class that is used to extend the capabilities of
servers that host applications accessed by means of a request-response programming
model.
• There are two main types of servlets as Generic and HTTP servlet.
Elements required:
• <form>
• <script>
• <label>
• <input>
• <div>
• <style>
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.
23
4.Submit the form data to the server.
server.java:
1. Define the class server that extends the property of the class Http Servlet
2. Handle the request from the client by using the method service() of Http Servlet
class.
3. Get the parameter names from the HTML form by using the method get Parameter
Names().
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 Print Writer class.
CODING:
MySrv.java:
importjava.io.IOException; import
java.io.PrintWriter;
importjavax.servlet.ServletException; import
javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse; public class
MySrv extends HttpServlet {
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse) throws ServletException,
IOException {
response.setContentType("text/html");
PrintWriterout=response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">");
out.println("<HTML>");
out.println("<HEAD><TITLE>AServlet</TITLE></HEAD>");
out.println("<BODY>");
//GettingHTMLparametersfromServlet
Stringusername=request.getParameter("uname"); String
password=request.getParameter("pwd");
if((username.equals("user"))&&(password.equals("pswd")))
{
out.println("<h1>Welcometo"+username);
}
else
24
{
out.println("<h1>Registrationsuccess");
out.println("<ahref='./index.html'>ClickforHomepage</a>");
}
out.println("</BODY>");
out.println("</HTML>");
out.close();
}
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse) throws ServletException,
IOException {
doPost( request,response);
}
}
Registration.html:
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML><HEAD>
<TITLE>NewDocument</TITLE>
<METANAME="Generator" CONTENT="EditPlus">
<METANAME="Author" CONTENT="">
<METANAME="Keywords" CONTENT="">
<METANAME="Description" CONTENT="">
</HEAD>
<BODYbgcolor='#e600e6'>
<formaction='./MySrv'method="post"><center><h1><u>LoginPage</u></h1>
<h2>Username:<inputtype="text"name="uname"/> Password : <input
type="password" name="pwd"/>
<inputtype="submit"value="clickme"/>
</center>
</form>
</body>
</HTML>
web.xml:
<web-app>
<servlet>
<servlet-name>MySrv</servlet-name>
25
<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>
OUTPUT:
26
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the given to write a java program to invoke servlets from HTML form
is successfully verified and executed.
27
EX:NO:5
AIM:
To write a Java Program for Session Tracking Using Hidden Form Fields.
PROBLEMDESCRIPTION:
Java:
• Java is a widely used programming language for coding web
applications.
• Java is a multi-platform ,object oriented and network centric language that can beused as
a platform in itself.
Servlet:
• Servlet is an application that is running on a server.
• Servlet is a Java programming language class that is used to extend the capabilities ofservers
that host applications accessed by means of a request-response programming model.
• There are two main types of servlets as Generic and HTTP servlet.
Session ID:
• A session ID is a unique identification string usually a long, random and alpha-
numeric string ,that is transmitted between the client and the server.
• Session IDs are usually stored in the cookies ,URLs(incase url rewriting) andhidden
fields of Web pages.
• Common mechanisms used for sessiontrackingareCookies, SSLsessions,URL-
rewriting
Experiment required:
• <form>
• <script>
• <label>
• <input>
• <div>
• <style>
28
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 checkout.
4. Include the current items as hidden fields so they'll be passed on and submit to self.
CODING:
register.html:
<html>
<bodybgcolor="cyan">
<center>
<h1>WELCOMETOREGISTRATIONPAGE</h1>
<form action="./registerone" METHOD="post">
Name:<inputtype="text"name="name"><br><br>
Password:<inputtype="password"name="password"><br><br>PROFESSION:
<selectname="profession">
<optionvalue="engineer">ENGINEER</option>
<optionvalue="teacher">TEACHER</option>
<optionvalue="businessman">BUSINESSMAN</option>
</select><br><br>
<inputtype="submit"value="REGISTER">
</form>
</center>
</body>
</html>
web.xml
<web-app>
<welcome-file-list>
29
<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>
<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:
importjava.io.IOException; import
java.io.PrintWriter;
importjavax.servlet.ServletException; import
javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
publicclassRegistrationServletOneextendsHttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throwsServletException,IOException
{
30
Stringname=request.getParameter("name");
String password = request.getParameter("password");
Stringprofession=request.getParameter("profession");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><bodybgcolor=wheat>");
out.println("<center>");
out.println("<h1>COMPLETETHEREGISTRATION</h1>");
out.println("<form action = ./registertwo method = post");
out.println("<inputtype=hiddenname=namevalue="+name+">");
out.println("<input type = hidden name = password value =" + password + ">");
out.println("<inputtype=hiddenname=professionvalue="+profession
+">");
out.println("EMAILID:<inputtype=textname=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;
importjavax.servlet.ServletException; import
javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
publicclassRegistrationServletTwoextendsHttpServlet
{
31
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throwsServletException,IOException
{
Stringname=request.getParameter("name");
String password = request.getParameter("password");
Stringprofession=request.getParameter("profession"); String email =
request.getParameter("email");
String cell = request.getParameter("cell");
response.setContentType("text/html"); PrintWriter out =
response.getWriter();
out.println("<html><bodybgcolor=wheat>");
out.println("<center>");
out.println("<h1>REGISTRATIONSUCCESSFUL ........................</h1>");
out.println("</center>");
out.println("</body></html>"); out.close();
}
OUTPUT:
32
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the given To write a Java Program for Session Tracking Using
Hidden Form Fields is successfully verified and executed.
33
EX.NO:6
AIM:
To write program in Java to create three-tier applications using JSP and databases
for conducting online examination for displaying student mark list.
PROBLEM DESCRIPTION:
Java:
• Java is a widely used programming language for coding web
applications.
• Java is a multi-platform ,object oriented and network centric language that can be
used as a platform in itself.
JSP
• It stands for Java Server Pages.
• It is a server-side technology.
• It is used for creating web application.
• It is used to create dynamic web content.
• In this JSP tags are used to insert JAVA code into HTML pages.
• It is an advanced version of Servlet Technology.
• It is a Web based technology helps us to create dynamic and platform-
independent web pages.
• In this ,Java code can be inserted in HTML/XML pages or both.
• JSP is first converted into servlet by JSP container before
processing the client’s request.
PROCEDURE:
Steps for Creating Data Source for Microsoft Access drivers
1. Goto Control Panel and Select Administrative Tools and then select Data Source ODBC
icon. (or)
34
Go to Run (Press Window +R)and type odbcad32.exe to go Data Source ODBC.
2. Press Add Button.
3. Choose the driver for Microsoft Access.
4.Then, Press Finish Button.
5. Type Data Source Name as Exam Student.
6. Then Press "Select Button" and choose the data base file which is created already.
7. Then ,Press "OK" Button to complete the process.
Steps for Creating Data base and table for this Program:
1. Create Ms Access File in any Name
2. Then Open it.
3. Create the table in the name of Student Table With following columns Seat_no,
Name, Marks
CODING:
//OnlineExam.jsp
<%@pagelanguage="java"import="java.sql.*"%>
<%@pageimport="java.io.*"%>
<%@pageimport="java.util.*"%>
<%
StringSeatNum,Name;
Stringans1,ans2,ans3,ans4,ans5; int
a1,a2,a3,a4,a5; a1=a2=a3=a4=a5=0;
35
Connectionconnect=null;
Statement stmt=null; ResultSet
rs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url =
"jdbc:odbc:ExamStudent";
connect=DriverManager.getConnection(url,"",""); if(request.getParameter("action")!=null)
{
SeatNum=request.getParameter("Seat_no"); Name =
request.getParameter("Name");
ans1=request.getParameter("group1");
if(ans1.equals("True"))
a1=5;
else a1=0;
ans2=request.getParameter("group2");
if(ans2.equals("True"))
a2=0;
else a2=5;
ans3=request.getParameter("group3");
if(ans3.equals("True"))
a3=0;
else a3=5;
ans4=request.getParameter("group4");
if(ans4.equals("True"))
a4=5;
else a4=0;
ans5=request.getParameter("group5");
if(ans5.equals("True"))
a5=0;
36
else a5=5;
intTotal=a1+a2+a3+a4+a5;
stmt= connect.createStatement();
Stringquery="INSERTINTOStudentTable("+"Seat_no,Name,Marks"+") VALUES ('"
+SeatNum + "', '" + Name + "', '"+Total+ "')";
intresult=stmt.executeUpdate(query);
stmt.close();
stmt= connect.createStatement();
query="SELECT*FROMStudentTableWHEREName="+"'"+Name+"'"; rs =
stmt.executeQuery(query);
%>
<html><head><title>StudentMarkList</title></head>
<bodybgcolor=khaki>
<center>
StudentsMarksheet
NameoftheCollege:JAISHRIRAMENGINEERINGCOLLEGE
<tableborder="1"cellspacing="0"cellpadding="0">
<tr>
<td><b>Seat_No</b></td>
<td><b>Name</b></td>
<td><b>Marks</b></td>
</tr>
<%
while(rs.next())
{
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
</tr>
37
<%
}
rs.close();
stmt.close(); connect.close();
%>
</table>
</center>
<br/><br/><br/>
<table>
<tr><td><b>Date:<%=newjava.util.Date().toString()%></td></tr>
<tr><td><b>Signature:X.Y.Z.<b></td></tr>
</table>
<div>
Clickheretogoback
</body>
</html>
<%}else{%>
<html>
<head><title>OnlineExamination</title>
<scriptlanguage="javascript">
functionvalidation(Form_obj)
{
if(Form_obj.Seat_no.value.length==0)
{
alert("Please,filluptheSeatNumber");
Form_obj.Seat_no.focus();
returnfalse;
}
if(Form_obj.Name.value.length==0)
{
alert("Please,filluptheName");
Form_obj.Name.focus();
38
returnfalse;
}
returntrue;
}
</script>
</head>
<bodybgcolor=lightgreen>
<center>
OnlineExamination
</center>
<form action="OnlineExam.jsp" method="post"
name="entry"onSubmit="returnvalidation(this)">
<inputtype="hidden"value="list"name="action">
<hr/>
<table>
<tr>
<td>
SeatNumber:</td>
<td><inputtype="text"name="Seat_no"></td>
</tr>
<tr>
<td>
Name:</td>
<td><inputtype="text"name="Name"size="50"></td>
</tr>
<tr>
<td><b>TotalMarks:5*5=25</b></td>
<td></td><td></td><td></td><td><b>Time:15Min.</b></td>
</tr>
</table>
<hr/>
<b>1.XMLenablesyoutocollectinformationonceandreuseitina variety of ways.</b><br/>
39
<inputtype="radio"name="group1"value="True">True
<inputtype="radio"name="group1"value="False">False<br>
<br/>
<b>2.InModernPCthereisnocache memory.</b><br/>
<inputtype="radio"name="group2"value="True">True
<inputtype="radio"name="group2"value="False">False<br>
<br/>
<b>3.JavaScriptfunctionscannotbeusedtocreatescriptfragments that can be used over
and over again</b><br/>
<inputtype="radio"name="group3"value="True">True
<inputtype="radio"name="group3"value="False">False<br>
<br/>
<b>4.TheDriverManagerclassisusedtoopenaconnectiontoa database via
aJDBC driver.</b><br/>
<inputtype="radio"name="group4"value="True">True
<inputtype="radio"name="group4"value="False">False<br>
<br/>
<b>5.TheJDBCandODBCdoesnotshareacommonparent</b><br/>
<inputtype="radio"name="group5"value="True">True
<inputtype="radio"name="group5"value="False">False<br>
<hr/>
<center>
<inputtype="submit"value="Submit">
<inputtype="reset"value="Clear"><br><br>
</center>
</form>
<%}%>
40
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the given To write program in Java to create three-tier applications
using JSP and databases for conducting online examination for displaying student mark list is
successfully executed and verified.
41
EX.NO:7
DATE:
CREATION OF XML DOCUMENT
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.
PROBLEM DESCRIPTION:
XML:
• XML is a meta-markup language that provides a format for describing structured data.
• This facilitates more structured declarations of content and more meaningful search
result across multiple platforms.
• The start of XML markup elements is identified by either the less than symbol (), the
apostrophe or single quote (‘) and the double quotation marks (“) are used by XML
for markup.
• To use these special characters as content within your document, you must use the
corresponding general XML entity.
Elements required:
• <form>
• <script>
• <label>
• <input>
• <div>
• <style>
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
42
3. Get the user ID as input
4. Display the user’s information.
CODING:
index.html
<!DOCTYPEhtml>
<HTML>
<HEAD><TITLE>SearchingforXMLElements</TITLE>
<SCRIPT>
functionreadXMLData()
{
var xmlDocumentObject, id , name , addr, phone, email;
xmlDocumentObject=new XMLHttpRequest();
xmlDocumentObject.open("GET","userlist.xml",false);
xmlDocumentObject.send();
xmlDocumentObject=xmlDocumentObject.responseXML;id=xmlDocu
mentObject.getElementsByTagName("userid");
name=xmlDocumentObject.getElementsByTagName("username");
address=xmlDocumentObject.getElementsByTagName("address"); phone =
xmlDocumentObject.getElementsByTagName("phone"); email =
xmlDocumentObject.getElementsByTagName("email");
for(i=0;i<id.length;i++)
{
output=id[i].firstChild.nodeValue;
if(output==document.getElementById("myText").value)
{displayDIV.innerHTML = id[i].firstChild.nodeValue + "<br> " +
name[i].firstChild.nodeValue
+"<br>" +address[i].firstChild.nodeValue + "<br>" +
phone[i].firstChild.nodeValue+"<br>"+email[i].firstChild.nodeValue;
} }}
</SCRIPT></HEAD>
<BODY>
<H1>SearchUser</H1>
<inputtype="text"id="myText"value="">
43
<input type="BUTTON" VALUE="Get User Details"
ONCLICK="readXMLData()">
<P>
<DIVID="displayDIV"></DIV>
</BODY>
</HTML>
userlist.xml:
<userlist>
<userid>usr01</userid>
<username>Abi</username>
<address>Kovai</address>
<phone>9000067078</phone>
<email>[email protected]</email>
<userid>usr02</userid>
<username>Priya</username>
<address>Tiruppur</address>
<phone>9234567890</phone>
<email>[email protected]</email>
<userid>usr03</userid>
<username>sadhana</username>
<address>Avinashi</address>
<phone>9245228888</phone>
<email>[email protected]</email>
<userid>usr04</userid>
<username>Nasrin</username>
<address>Dindugal</address>
<phone>8877665543</phone>
<email>[email protected]</email>
<userid>usr05</userid>
<username>praveena</username>
<address>Perambalur</address>
<phone>8675432109</phone>
<email>[email protected]</email>
44
</userlist>
OUTPUT:
45
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the 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 is successfully executed and verified.
46
EX:NO:8
A.FORM VALIDATION USING PHP
DATE:
REGULAR EXPRESSION
AIM:
To validate the form using PHP regular expression.
PROBLEM DESCRIPTION:
PHP:
• PHP stands for Hyper text Pre-processor.
• General Purpose scripting language
• Embeded PHP code into HTML
Elements required:
• <form>
• <script>
• <label>
• <input>
• <div>
• <style>
PROCEDURE:
1. Form is created for class registration with fields.
2. These fields are validated using PHP code.
3. Form is displayed.
CODING:
index.php:
<!DOCTYPEHTML>
<html>
<head>
<style>
.error{color:#FF0000;}
</style>
47
</head>
<body>
<?php
$nameErr=$emailErr=$genderErr=$websiteErr="";
$name=$email=$gender=$comment=$website=""; if
($_SERVER["REQUEST_METHOD"] == "POST") {
if(empty($_POST["name"])) {
$nameErr="Nameisrequired";
} else {
$name =test_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z-']*$/",$name)){
$nameErr="Onlylettersandwhitespace allowed";
}
}
if(empty($_POST["email"])) {
$emailErr="Emailis required";
} else {
$email =test_input($_POST["email"]);
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
$emailErr="Invalidemailformat";
}
}
if(empty($_POST["website"])){
$website="";
} else {
$website=test_input($_POST["website"]);
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-
9+&@#\/%?=~_|!:,.;]*[-a-z0-
9+&@#\/%=~_|]/i",$website)){
$websiteErr="InvalidURL";
}
}
if(empty($_POST["comment"])){
48
$comment="";
} else {
$comment=test_input($_POST["comment"]);
}
if(empty($_POST["gender"])){
$genderErr="Genderisrequired";
} else {
$gender=test_input($_POST["gender"]);
}}
functiontest_input($data){
$data=trim($data);
$data=stripslashes($data);
$data=htmlspecialchars($data); return $data;
}
?>
<h2>PHPFormValidationExample</h2>
<p><spanclass="error">*requiredfield</span></p>
<form method="post" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name:<inputtype="text"name="name"value="<?phpecho$name;?>">
<spanclass="error">*<?phpecho$nameErr;?></span>
<br><br>
E-mail:<inputtype="text"name="email"value="<?phpecho$email;?>">
<spanclass="error">*<?phpecho$emailErr;?></span>
<br><br>
Website: <input type="text" name="website" value="<?php echo
$website;?>">
<spanclass="error"><?phpecho$websiteErr;?></span>
<br><br>
Comment:<textareaname="comment"rows="5"cols="40"><?phpecho
$comment;?></textarea>
<br><br>
49
Gender:
<inputtype="radio"name="gender"<?phpif(isset($gender)&&
$gender=="female")echo"checked";?>value="female">Female
<input type="radio" name="gender" <?php if (isset($gender) &&
$gender=="male")
echo"checked";?>value="male">Male
<input type="radio" name="gender" <?php if (isset($gender) &&
$gender=="other")
echo"checked";?>value="other">Other
<spanclass="error">*<?phpecho$genderErr;?></span>
<br><br>
<inputtype="submit"name="submit"value="Submit">
</form>
<?php
echo"<h2>YourInput:</h2>"; echo
$name;
echo "<br>"; echo
$email; echo
"<br>"; echo
$website; echo
"<br>";
echo$comment;
echo "<br>"; echo
$gender;
?>
</body>
</html>
50
OUTPUT:
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the to validate the form using PHP regular expression is successfully
executed and verified.
51
EX:NO:
B. STORING A FORM DATA IN PHP
DATE:
AIM:
PROBLEM DESCRIPTION:
Elements required:
• <form>
• <script>
• <label>
• <input>
• <div>
• <style>
PROCEDURE:
1. Form is created with fileds name,mail id,contact and address.
2. Table is created in my sql.
3. The input data entered into the fields are stored using PHP code.
CODING:
index.php:
<!DOCTYPEhtml>
<html>
<head>
<style>
.error{color:#FF0000;}
</style>
</head>
<body>
<?php
$nameErr=$emailErr=$genderErr=$websiteErr="";
52
$name=$email=$gender=$comment=$website=$result=""; if
($_SERVER["REQUEST_METHOD"] == "POST") {
if(empty($_POST["name"])){
$nameErr="Nameis required";
} else {
$name=test_input($_POST["name"]);
if(!preg_match("/^[a-zA-Z]*$/",$name)) {
$nameErr="Onlylettersandwhitespaceallowed";
}
}
if(empty($_POST["email"])){
$emailErr="Emailis required";
} else {
$email=test_input($_POST["email"]);
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
$emailErr="Invalidemailformat";
}
}
if(empty($_POST["website"])){
$website="";
} else {
$website=test_input($_POST["website"]);
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-
9+&@#\/%?=~_|!:,.;]*[-a-z0-
9+&@#\/%=~_|]/i",$website)){
$websiteErr="InvalidURL";
}
}
if(empty($_POST["comment"])){
$comment="";
} else {
$comment=test_input($_POST["comment"]);
}
53
if(empty($_POST["gender"])){
$genderErr="Genderisrequired";
} else {
$gender=test_input($_POST["gender"]);
}
$servername="localhost";
$username="root";
$password="";
$dbname="iplab";
$conn=newmysqli($servername,$username,$password,$dbname); if ($conn-
>connect_error) {
die("Connectionfailed:".$conn->connect_error);
}
$sql="INSERTINTOregister(name,email,website,comments,gender) VALUES ('$name',
'$email', '$website','$comment', '$gender')";
if($conn->query($sql)===TRUE){
$result="NewRecordInsertedSuccessfully";
} else { echo"Error:".$sql."<br>".$conn-
>error;
}
$conn->close();
}
functiontest_input($data){
$data=trim($data);
$data=stripslashes($data);
$data=htmlspecialchars($data); return
$data;
}
?>
<h2>RegistrationForm</h2>
<p><spanclass="error">*requiredfield</span></p>
<form method="post" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]);?>">
54
Name:<inputtype="text"name="name">
<spanclass="error">*<?phpecho$nameErr;?></span>
<br><br>
E-mail:<inputtype="text"name="email">
<spanclass="error">*<?phpecho$emailErr;?></span>
<br><br>
Website:<inputtype="text"name="website">
<spanclass="error"><?phpecho$websiteErr;?></span>
<br><br>
Comment:<textareaname="comment"rows="5"cols="40"></textarea>
<br><br> Gender:
<inputtype="radio"name="gender"value="female">Female
<inputtype="radio"name="gender"value="male">Male
<spanclass="error">*<?phpecho$genderErr;?></span>
<br><br>
<inputtype="submit"name="submit"value="Submit">
</form>
<?php
echo$result;
?>
</body>
</html>
55
OUTPUT:
56
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the to store a PHP form data into data base is successfully executed andverified.
57
EX.NO:8
AIM:
To Write web services for finding what people think by asking 500 people’s opinion
for any consumer product.
PROBLEM DESCRIPTION:
Web Services
• Web service is a means of communication between devices or applications to
provide a service, similar to the way humans communicate to perform services
for one another.
Elements required:
• <form>
• <script>
• <label>
• <input>
• <div>
• <style>
PROCEDURE:
1. Open the home page.
2. Enter the login ID and type the comments then submit.
3. Retrieve comments with post id
4. Display the comments.
CODING:
Index.php
<!doctypehtml>
<htmllang="en">
<head>
<metacharset="UTF-8"/>
<title>jQueryAjaxCommentSystem-Demo</title>
58
<linkrel="stylesheet"href="css/style.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<scriptsrc="js/script.js"></script>
</head>
<body>
<div class="wrap">
<h1>MaggyNoodlesCommentSystem</h1>
<?php
// retrive post
include('config.php');
include('function.php');
dbConnect();
$query=mysql_query(
'SELECT *
FROMpost
WHEREpost_id=1');
$row=mysql_fetch_array($query);
?>
<div class="post">
<h2><?phpecho$row['post_title']?></h2>
<p><?phpecho$row['post_body']?></p>
</div>
<?php
//retrivecommentswithpostid
$comment_query=mysql_query( "SELECT *
FROMcomment
WHEREpost_id={$row['post_id']} ORDER
BY comment_id DESC LIMIT 15");
?>
59
<h2>Comments .......... </h2>
<divclass="comment-block">
<?phpwhile($comment=mysql_fetch_array($comment_query)):?>
<divclass="comment-item">
<divclass="comment-avatar">
<imgsrc="<?phpechoavatar($comment['mail'])?>"alt="avatar">
</div>
<divclass="comment-post">
<h3><?phpecho$comment['name']?><span>said .........................</span></h3>
<p><?phpecho$comment['comment']?></p>
</div>
</div>
<?phpendwhile?>
</div>
<h2>Submitnewcomment</h2>
<!--commentform-->
<formid="form"method="post">
<!--needtosupplypostidwithhiddenfild -->
<inputtype="hidden"name="postid"value="<?phpecho$row['post_id']?>">
<label>
<span>Name*</span>
<inputtype="text"name="name"id="comment-name"placeholder="Your name here ... "
required>
</label>
<label>
<span>Email*</span>
<inputtype="email"name="mail"id="comment-mail"placeholder="Your mail here ...."
required>
</label>
<label>
<span>Yourcomment*</span>
<textarea name="comment" id="comment" cols="30"
rows="10"placeholder="Type your comment
60
here ..."required></textarea>
</label>
<inputtype="submit"id="submit"value="SubmitComment">
</form>
</div>
</body>
</html> Ajax_Comment.php
<?php
if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])):
include('config.php');
include('function.php');
dbConnect();
if(!empty($_POST['name'])AND!empty($_POST['mail'])AND
!empty($_POST['comment'])AND!empty($_POST['postid'])){
$name=mysql_real_escape_string($_POST['name']);
$mail= mysql_real_escape_string($_POST['mail']);
$comment=mysql_real_escape_string($_POST['comment']);
$postId=mysql_real_escape_string($_POST['postid']);
mysql_query("
INSERTINTOcomment
(name,mail,comment,post_id)
VALUES('{$name}','{$mail}','{$comment}','{$postId}')");
}
?>
<divclass="comment-item">
<divclass="comment-avatar">
<imgsrc="<?phpechoavatar($mail)?>"alt="avatar">
</div>
<divclass="comment-post">
<h3><?phpecho$name?><span>said ..................... </span></h3>
<p><?phpecho$comment?></p>
</div>
61
</div>
<?php
dbConnect(0);
endif?> Config.php
<?php
# db configuration
define('DB_HOST','localhost');
define('DB_USER', 'root');
define('DB_PASS', 'root');
define('DB_NAME','dbname');
?>
Function.php
<?php
/**
* Connecttomysqlserver
* @parambool
* @usetruetoconnectfalseto close
*/
functiondbConnect($close=true){ if
(!$close) {
mysql_close($link);
return true;
}
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect to
MySQLDB').mysql_error();
if(!mysql_select_db(DB_NAME,$link)) return
false;
}
/**
* gravatarImage
* @seehttp://en.gravatar.com/site/implement/images/
62
*/
functionavatar($mail,$size=60){
$url="http://www.gravatar.com/avatar/";
$url.=md5(strtolower(trim($mail)));
//$url.="?d=".urlencode($default );
$url.="&s=".$size; return $url;
}
?>
Style.CSS
/*generalstyling */
*{
margin:0;
padding:0;
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-font-smoothing:antialiased;
-moz-font-smoothing:antialiased;
-o-font-smoothing:antialiased; font-
smoothing: antialiased;
text-rendering:optimizeLegibility;
}
body{
font:12pxArial,Tahoma,Helvetica,FreeSans,sans-serif; text-
transform: inherit;
color: #333;
background:#e7edee; width:
100%;
text-shadow:01px1pxrgba(0,0,0,0.2)
}
.wrap{
width:720px;
63
margin: 15px auto;
padding:15px20px;
background: white;
border:2pxsolid#DBDBDB;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius: 5px; overflow:
hidden;
}
a{text-decoration:none;color:#333} h1{
font-family:Georgia,"TimesNewRoman",Times,serif; font-size:
2.8em;
text-align:center;
margin: 25px 0;
}
h2{font-size:1.5em;margin:8px0} h3{
font-size:1.2em;
margin: 5px 0;
}
h3span{
font-weight:normal;
font-size: 1em;
}
.item{clear:b
oth;
margin:0;
padding: 10px;
overflow:hidden;
border-top:1pxsolid#DBDBDB;
}
.item:last-child{border-bottom:1pxsolid#DBDBDB}
64
.item:hover{background:#f9f9f9}
.post{
padding:10px0;
border-bottom:1pxsolid#E6E6E6;
}
.comment-block{
margin:20px020px20px;
}
.comment-item{
overflow:hidden;
width: 500px; clear:
both; padding: 10px;
border:1pxsolid#E6E6E6;
border-radius: 5px;margin: 5px;
}
.comment-avatar{
width: 60px; float:
left;
}
.comment-avatarimg{ width:
60px;
height: 60px; border-
radius:5px;
}
.comment-post{
width: 400px; float:
left;
padding:05px010px;
}
#form{
clear:both;
65
margin:10px;
width:500px;
}
/* form styling */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea { width:100%;
background: #fff;
border:1pxsolid#ddd; font-
size: 13px;
line-height: 20px;
margin: 0;
padding:7px10px;
box-shadow:inset01px2px#eee; border:1px
solid #CCC;
margin:0 0 5px;
border-radius:5px;
}
textarea {
height:100px; max-
width:100%;
}
input[type="submit"] {
cursor:pointer; width:100%;
border:none;
background:#991D57;
background-image:linear-gradient(bottom,#8C1C500%,#991D5752%);
background-image:-moz-linear-gradient(bottom,#8C1C500%,#991D57 52%);
66
background-image:-webkit-linear-gradient(bottom, #8C1C50 0%, #991D57 52%);
color:#FFF; margin:0
0 5px; padding:10px;
border-radius:5px;
}
input[type="submit"]:hover{
background-image:linear-gradient(bottom,#9C215A0%,#A8276752%);
background-image:-moz-linear-gradient(bottom,#9C215A0%,#A82767 52%);
background-image:-webkit-linear-gradient(bottom,#9C215A0%,#A82767 52%);
-webkit-transition:background0.3sease-in-out;
-moz-transition:background0.3sease-in-out;
transition:background-color0.3sease-in-out;
}
input[type="submit"]:active{
box-shadow:inset01px3pxrgba(0,0,0,0.5);
}
input:focus,
textarea:focus{
outline:0;
border:1pxsolid#999;
}
label{
display:block;
margin:5px0;
font-weight:900;
cursor: pointer;
}
.alert{display:no
ne;
67
padding:8px35px8px14px; margin:
20px 0;
text-shadow:01px0rgba(255,255,255, 0.5);
color: #468847; background-
color:#dff0d8; border-color:
#d6e9c6;
-webkit-border-radius:4px;
-moz-border-radius:4px;
border-radius: 4px;
}
Script.js
$(document).ready(function(){ var
form = $('form');
var submit = $('#submit');
form.on('submit',function(e){
//preventdefaultaction
e.preventDefault();
//sendajaxrequest
$.ajax({
url:'ajax_comment.php', type:
'POST',
cache: false,
data:form.serialize(),//formserizlizedata beforeSend:
function(){
// change submit button value text and disabled it
submit.val('Submitting...').attr('disabled','disabled');
},
success:function(data){
//AppendwithfadeInseehttp://stackoverflow.com/a/978731 var item =
$(data).hide().fadeIn(800);
$('.comment-block').append(item);
//resetformandbutton
form.trigger('reset');
68
submit.val('SubmitComment').removeAttr('disabled');
},
error:function(e){
alert(e);
}
});
});
});
OUTPUT:
69
Performance 20
Program 40
Result 20
Record 20
Total 100
RESULT:
Thus the To Write web services for finding what people think by asking 500people’s
opinion for any consumer product is successfully executed and verified.
70