Web Programming MATERIAL
Web Programming MATERIAL
}
h1 {background-color: pink}
h2 {background-color: transparent}
p {background-color: rgb(25,20,25)}
</style>
8 Write the style sheet for displaying text with a different background and bigger font size? 2 K1
<style type="text/css">
body
{
background-image: url("img149.jpg");
background-repeat: repeat
}
h1 {background-color: pink}
h2 {background-color: transparent}
p {background-color: rgb(25,20,25)}
</style>
9 Write a DHTML program for performing font operations. 2 K1
body
{
background-color:skycolor;
}
h1{
class="veryimportant";
font-size: 20pt;
color: red;
}
p
{
font-size: 16pt; word-spacing:1 em;
text-indent: 0.5in;
}
a:link{color:blue;}
a:visited{color:red;}
10 Define scriptlets 2 K1
Scriptlets enable you to create small, reusable web applications that can be used in any web
page. Scriptlets are created using HTML, scripting and Dynamic HTML. To include them in
an HTML document use the <OBJECT> tag.
11 List of key features of DHMTL in internet explorer? 2 K1
Dynamic loading web pages, interactive pages, embedding multimedia objects
12 List the global HTML attributes with their purpose? 2 K1
Attribute Description
style Specifies an inline CSS style for an element
tabindex Specifies the tabbing order of an element
title Specifies extra information about an element
translate Specifies whether the content of an element should be translated or not
CO2 : Develop web pages using java script.
1 Write a javascript to display the position of mouse click? K2
function printMousePos() {
var cursorX;
var cursorY;
document.onmousemove = function(e){
cursorX = e.pageX;
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
cursorY = e.pageY;
}
document.getElementById('test').innerHTML = "x: " + cursorX + ", y: " + cursorY;
}
2 Differentiate VBScript and JavaScript. 2
JavaScript allows client-side scripts to interact with the users, communicate asynchronously,
control the browsers and alter the web page content which is displayed can be achieved
through JavaScript.
VBScript is a general scripting language developed on visual basic and developed by
K2
Microsoft. It is also called as an active scripting language. It is a visual basic edition scripting
language as it is developed (modeled) based on visual basic to be a lightweight scripting
language with a fast interpreter. VBScript is supported only by browser Internet Explorer and
it is mostly used in Microsoft environments and visual basic language products. It will be
installed by default in every windows desktop version.
3 Write a javascript code to perform arithmetic operations. 2 K2
var var1 = 45;
var var2 = 78;
var var3 = 45.10;
var var4 = 178.12;
var newvar = var1 + var2;
var newvar1 = var3 + var4;
var newParagraph3 = document.createElement("p");
var newText3 = document.createTextNode("var1 + var2 = "+newvar+" and var3 + var4 =
"+newvar1);
newParagraph3.appendChild(newText3);
document.body.appendChild(newParagraph3);
4 Why we need scripting languages? 2 K2
Scripting languages – perform problem solving operation in web pages
5 What is the benefit of using JavaScript code in an HTML document? 2 K1
JavaScript allows client-side scripts to interact with the users, communicate asynchronously,
control the browsers and alter the web page content which is displayed can be achieved
through JavaScript.
6 List out the objects involved in JavaScript with its purpose. 2 K1
Value Type Comment
"Hello" string "Hello" is always "Hello"
3.14 number 3.14 is always 3.14
true boolean true is always true
false boolean false is always false
null null (object) null is always null
undefined undefined undefined is always undefined
7 Write a javascript to print a mark list for 10 students in a HTML table. 2 K2
<table>
<%for(int v=1;v<=l;v++){System.out.println("l value"+l);String
cnames=rsmt.getColumnName(v);%>
<td width="50%"><font face="Arial, Helvetica" color = 'red'
size='5'><b><i><%=cnames.toUpperCase()%></i></b></font></td>
<%}%>
</tr><%
while(datars.next()){%>
<tr><%for (int vc=1;vc<=l;vc++){%>
<td width="50%"><font face="Arial,
Helvetica"><%=datars.getString(vc)%></font></td><%
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
}
}%></table>
8 Write a JavaScript code to find out odd and even number generation. 2 K2
<html >
<head>
<title>Test</title>
</head>
<body>
<script type="text/javascript">
/* <! */
var i;
for (i = 0; i < 1000; i++)
if ((i % 2) == 0)
document.writeln(i);
/* ]]> */
</script>
</body>
</html>
9 Write a Java script to use break and continue syntax 2 K2
<html>
<body>
<script type = "text/javascript">
<!--
var x = 1;
document.write("Entering the loop<br /> ");
document.write(var1+"<br />");
document.write(var2+"<br />");
for(var i=3; i <= num;i++)
{
var3 = var1 + var2;
var1 = var2;
var2 = var3;
document.write(var3+"<br />");
}
// -->
</script>
</body>
</html>
11 Write the java script to apply functions 2 K2
var numbers = [5, 6, 2, 3, 7];
The client-side environment used to run scripts is usually a browser. The processing takes
place on the end users computer. The source code is transferred from the web server to the K2
users computer over the internet and run directly in the browser.
The scripting language needs to be enabled on the client computer. Sometimes if a user is
conscious of security risks they may switch the scripting facility off. When this is the case a
message usually pops up to alert the user when script is attempting to run.
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Server-side Environment
The server-side environment that runs a scripting language is a web server. A user's request is
fulfilled by running a script directly on the web server to generate dynamic HTML pages.
This HTML is then sent to the client browser. It is usually used to provide interactive web
sites that interface to databases or other data stores on the server.
This is different from client-side scripting where scripts are run by the viewing web browser,
usually in JavaScript. The primary advantage to server-side scripting is the ability to highly
customize the response based on the user's requirements, access rights, or queries into data
stores.
2 Define Servlet Cookies 2 K1
A cookie is a small piece of information that is persisted between the multiple client requests.
A cookie has a name, a single value, and optional attributes such as a comment, path and
domain qualifiers, a maximum age, and a version number. By default, each request is
considered as a new request. In cookies technique, we add cookie with response from the
servlet. So cookie is stored in the cache of the browser. After that if request is sent by the
user, cookie is added with request by default. Thus, we recognize the user as the old user.
3 Write a note on Internet Information Server (IIS). 2 K1
Microsoft's Web server that runs on Windows NT platforms, In fact, IIS comes bundled with
Windows NT 4.0. Because IIS is tightly integrated with the operating system, it is relatively
easy to administer. However, currently IIS is available only for the Windows NT platform,
whereas Netscape' s Web servers run on all major platforms, including Windows NT
platform, OS/2 and UNIX.
4 List the advantages of CGI scripting 2 K1
1. CGI programs are relatively safe to run.
2. A CGI program can crash without damaging the server, since it only has limited access to
the server.
3. Reduces the burden of server
a. Sends prepared messages / mails e customer reply
b. Capability to process forms and prepares output based on form input.
c. Hit counts / Page counters.
5 What is meant by Stateless Connection? 2 K1
When a web server receives a HTTP request from a web browser it evaluates the request and
returns the requested document, if it exists, and then breaks the HTTP connection. This
document is preceded by the response header, which has details about how to display the
document that will be sent by the server. Each time a request is made to the server, it is as if
there was no prior connection and each request can yield only a single document. This is
known as Stateless Connection.
6 What are cookies and how it will be useful in website 2 K2
Cookies are a message given to a Web browser by a Web server. The browser stores the
message in a text file. A cookie is a baked or cooked food that is typically small, flat and
sweet. It usually contains flour, sugar and some type of oil or fat
7 Draw the architecture of servlet 2 K1
In programming, an event is an action that occurs as a result of the user or another source,
such as a mouse being clicked, or a key being pressed. An event handler is a routine that is
used to deal with the event, allowing a programmer to write code that will be executed when
the event occurs.
9 List out various event handlers 2 K1
Event handler Applies to: Triggered when:
onAbort Image The loading of the image is cancelled.
onBlur Button, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select,
Submit, Text, TextArea, Window The object in question loses focus (e.g. by
clicking outside it or pressing the TAB key).
onChange FileUpload, Select, Text, TextArea The data in the form element is
changed by the user.
onClick Button, Document, Checkbox, Link, Radio, Reset, Submit The object is
clicked on.
10 Write a note on Environment variables 2 K1
In CGI, the server prepares the environment variables before it launches the CGI script. These
represent the current state of the server that is asking for the information. The environment
variables are not set from the command line but are created on the fly, and lasts only until that
particular script is finished. Each script gets its own unique set of variables and multiple
scripts can be executed at once, each in its own environment
11 What are STDIN and STDOUT? 2 K1
These are mnemonics for standard input and standard output, two predefined stream / file
handles. Each process already inherits these two handles already open. From the script's point
of view, STDIN is what comes from the browser via the server when the post method is used,
and the STDOUT is where it writes its output back to the browser. The script picks up the
environment variables and reads STDIN as appropriate. It then does whatever it was designed
to do and writes its output to STDOUT.
12 Explain about Session tracking 2 K2
A session is basically a conversation between a browser and a server. All the above
technologies can save information for the current session for a particular user visiting a site.
The session is important, as H1TP is a stateless protocol. This means that the connection
between web server and a web browser is not automatically maintained, and that the state of a
web session is not saved.
CO4: Apply database concept to create interactive web pages.
1 What is Electronic Data Interchange(EDI)? K1
Electronic Data Interchange (EDI) is the electronic interchange of business information using a
standardized format; a process which allows one company to send information to another company
electronically rather than with paper. Business entities conducting business electronically are called
trading partners.
2 What operations Multicast Socket Perform? 2 K1
Class MulticastSocket
java.lang.Object
java.net.DatagramSocket
java.net.MulticastSocket
All Implemented Interfaces:
Closeable, AutoCloseable
public class MulticastSocket
extends DatagramSocket
The multicast datagram socket class is useful for sending and receiving IP multicast packets.
A MulticastSocket is a (UDP) DatagramSocket, with additional capabilities for joining
"groups" of other multicast hosts on the internet.
A multicast group is specified by a class D IP address and by a standard UDP port number.
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
9 Write the java code to connect database using connection string and resultset 2 K2
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
"jdbc:oracle:thin:@localhost:1521:xe","system","password");
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next()){
System.out.println(rs.getInt(1)+" "+rs.getString(2));
}
10 List out various java classes in JDBC 2 K1
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the
query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC
drivers to connect with the database. There are four types of JDBC drivers:
JDBC-ODBC Bridge Driver,
Native Driver,
Network Protocol Driver, and
Thin Driver
11 Draw the structure of JDBC 2 K1
<body>
<%
for(int i=0;i<=10;i++)
{
if((i%2)==0)
{
out.print("Even number :"+i);
out.print("<br>");
}
}
%>
</body>
</html>
2 What is use of XML Namespace and give syntax 2 K1
XML Namespace is a mechanism to avoid name conflicts by differentiating elements or
attributes within an XML document that may have identical names, but different
definitions. We will be covering the basics ofnamespace, including declaration methods,
scope, attribute namespace, and default namespace.
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
<body>
<%
int a=5;
int b=2;
int result=a-b;
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
SOAP is an XML-based protocol for accessing web services over HTTP. It has some
specification which could be used across all applications.
SOAP is known as the Simple Object Access Protocol, but in later times was just shortened to
SOAP v1.2. SOAP is a protocol or in other words is a definition of how web services talk to
each other or talk to client applications that invoke them.
3 What do you meant by WSDL? 2 K1
WSDL is an XML format for describing network services as a set of endpoints operating on
messages containing either document-oriented or procedure-oriented information. The
operations and messages are described abstractly, and then bound to a concrete network
protocol and message format to define an endpoint
4 Specifies Actors role in SOAP. 2 K1
SOAP actor or role definition is: Actor or Role is a global attribute can be used to indicate the
recipient of a header element. The value of the SOAP actor attribute is a URI.
5 What is RMI? 2 K1
The RMI (Remote Method Invocation) is an API that provides a mechanism to create
distributed application in java. The RMI allows an object to invoke methods on an object
running in another JVM.
The RMI provides remote communication between the applications using two objects stub
and skeleton.
6 What is XML protocol Working Group? 2 K1
The XML Protocol ("XMLP") is a standard being developed by the W3C XML Protocol
Working Group to the following guidelines, outlined in the group's charter: An envelope for
encapsulating XML data to be transferred in an interoperable manner that allows for
distributed extensibility.
7 Define SMIL modularization? 2 K1
SMIL functionality is partitioned into modules based on the following design requirements:
Ensure that a profile may be defined that is completely backward compatibility with SMIL
1.0.
Ensure that a module's semantics maintain compatibility with SMIL semantics (this includes
content and timing).
Specify modules that are isomorphic with other modules based on W3C recommendations.
Specify modules that can complement XHTML modules.
Adopt new W3C recommendations when appropriate and not in conflict with other
requirements.
Specify how the modules support the document object model.
8 What do you mean by XPath, XLink, XPointer? 2 K1
XPath is a language that views the XML document as a tree with nodes. Using XPath, you
can locate any node in the XML document tree. XPointer provides a way to address the
internal structure of an XML document.
9 Write a DTD code for given XML Document 2 K2
<manager>
<customer>
<customer name> …..</customer name>
</customer>
<manager name>……..</manager name>
<company name>………</company name>
</manager>
<!DOCTYPE address [
<!ELEMENT address (name,company,phone)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
]>
<address>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</address>
10 Draw mosquito preview for XForms. 2 K1
XForms is the new markup language for forms on the Web. This document is a quick
introduction to XForms for HTML Forms authors. It shows you how to convert existing
forms to their XForms equivalent. It assumes knowledge of HTML Forms, so is not a
beginner's tutorial. Although there is mention of additional facilities of XForms beyond those
possible in HTML Forms (marked with an asterisk on the headings), it is not a full tutorial on
all features of XForms.
11 What are the uses of XML? 2 K1
General applications: XML provides a standard method to access information, making it
easier for applications and devices of all kinds to use, store, transmit, and display data.
12 Draw the Structure of Web Service Architecture 2 K1
In HTML we can split the screen into several parts called frames and we can display various
pages in each frame. Frames can be created - 2 marks
<FRAMESET>
Attributes – 2 marks
cols = values
This is used to split the screen vertically. The value of this attribute is the ratio in
which the screen is to be divided. rows = values
This is same as col except that it divides the screen horizontally.
<FRAME>
This tag is used to describe the content of each frame.
Attributes
SRC = path – 2 marks
This is used to specify the path of the file to be displayed in the frame.
NAME = value – 1 Mark
This is used to naming the frame for further use.
<NO FRAME> - 1 Mark
Sample Program – 4 marks
3 Write the script to print list items using ordered and unordered list K2
Lists in HTML are used to list the items using bullets and numbers. There are here types of
lists. They are :Ordered List, Unordered List, Definition List – 2 marks
Ordered List
Ordered list is used to list the items using numbers or alphabets. Tag used to create
an ordered list is <OL>………………..</OL>
Un ordered List
Un ordered list is used to list items using symbols called bullets. Tag used to create
unordered list is <UL>…………………..</UL>
<LI> tag 12
In both ordered and un ordered list, <LI> tag should precedes each item in a list.
Create the image.html with CSS for setting the images at the correct index position
<style type="text/css"> - 2 marks
#img1{position:absolute;left:"260px";top:"230px"}
#img2{position:absolute;left:"290px";top:"260px"}
#img3{position:absolute;left:"320px";top:"290px"}
</style>
The three images are loaded into the web page with the tag - 2 marks
<img id="img2" src="gold petals.jpg" width="250px" height="300px" onClick="image2()">
The images can also be inserted using the following tag
<object height=70% width=75% type='image/jpeg' data='waterfall.jpg'></object>
Program – 8 marks
CO2: Develop web pages using java script.
1 Describe JavaScript Variables and DataTypes 12
JavaScript Data Types – 6 marks
i. Primitive data types
ii. Syntax
iii. Example K2
JavaScript Variables – 6 marks
i. Variable declaration and assignment
ii. Syntax
iii. Example
2 Design a web page to detect the visitor’s browser name and version using javascript?
Aim and procedure – 3 marks
Structure of the code – 3 mark
12 K3
Script syntax – 2 mark
Build-in syntax – 2 marks
Printing codes – 2 mark
3 Explain about javascript global function?
Definition of global function and Syntax – 3 marks
parseInt(x, [radix]) – 3 marks 12 K2
parseFloat(x) - 3 marks
Sample program - 3 marks
4 Create a script that prompts the user for a number and then counts from 1 to that number
displaying only the odd numbers.
<html>
<body>
<script type="text/javascript">
var count,f1,f2,f3;
var fib=new Array(10);
f1=1;
f2=-1;
for(count=0;count<10;count++)
12 K3
{
f3=f1+f2;
fib[count]=f3;
f2=f1;
f1=f3;
}
document.writeln("loop");
for(count in fib)
{
document.writeln("<b>"+fib[count]+"<b>");
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
}
</script>
</body>
</html>
5 Write the PHP program to display the details of Faculty 12 K3
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form method='POST'>
<h2>Please input your name:</h2>
<input type="text" name="name">
<input type="submit" value="Submit Name">
</form>
<?php
//Retrieve name from query string and store to a local variable
$name = $_POST['name'];
echo "<h3> Hello $name </h3>";
?>
</body>
</html>
CO3: Develop server side programming techniques to solve real time application.
1 Explain in detail about Microsoft IIS?
Abbreviation and Definition of IIS – 3 marks
Uses and Versions – 3 mark 12 K2
Protocols – 3 marks
Working principle – 3 marks
2 Write a script to display a drop down menu? K2
Aim and procedure – 3marks
Form creation – 2 mark 12
Accessing database – 2 mark
Events – 2 marks
Span definition – 3 marks
3 Describe Cookies in detail. K2
Definition and use of cookies - 3 marks
Syntax – 3 marks 12
Request and Response commands – 3 marks
Sample program – 3 marks
4 Explain Sessions in detail? K2
Steps and Syntax – 3 marks
Accessing the session object associated with the current request.
Looking up information associated with a session. 12
Storing information in a session – 3 marks
Discarding session data – 3 marks
Accessing the Session Object Associated with the Current Request – 3 marks
CO4: Apply database concept to create interactive web pages. K3
1 Write the java program for Connecting a java servlet program to a database for stock
maintenance
12
create database sonoo;
use sonoo;
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
12
3 Draw the Life Cycle of a Java Servlet and explain each stage with example K2
The web container maintains the life cycle of a servlet instance. Let's see the life cycle of the
servlet: 12
2 marks
4 Explain the different Types of JDBC Connections in Servers? K2
Type 1: JDBC-ODBC bridge
Type 2: partial Java driver
Type 3: pure Java driver for database middleware
Type 4: pure Java driver for direct-to-database
Type 5: highly-functional drivers with superior performance
12
5 Illustrate about the methods used in reading servlet parameters and reading initialization K2
parameters.
<web-app>
<servlet>
......
<init-param>
<param-name>parametername</param-name>
12
<param-value>parametervalue</param-value>
</init-param>
......
</servlet>
</web-app>
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
12
name is optional.
targetNamespace is the logical namespace for information about this service. WSDL
documents can import other WSDL documents, and setting targetNamespace to a unique
value ensures that the namespaces do not clash.
xmlns is the default namespace of the WSDL document, and it is set to
http://schemas.xmlsoap.org/wsdl/.
All the WSDL elements, such as <definitions>, <types> and <message> reside in this
namespace.
xmlns:xsd and xmlns:soap are standard namespace definitions that are used for specifying
SOAP-specific information as well as data types.
xmlns:tns stands for this namespace.
xmlns:ns1 is set to the value of the schema targetNamespace, in the <types> section.
4 Describe three main capabilities for including files and applets into a JSP document. K2
i) jsp:include action 12
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
This includes generated page, not JSP code. It cannot access environment of main
page in included code.
ii) include directive
Include directive includes dynamic page, i.e., JSP code. It is powerful, but poses
maintenance challenges.
iii) jsp:plugin action
This inserts applets that use the Java plug-in. It increases client side role in dialog.
Now, we will discuss in details about this capability of JSP.
• Including Files at Page Translation Time
You can include a file with JSP at the page translation time. In this case file will be
included in the main JSP document at the time the document is translated into a
servlet (which is typically the first time it is accessed).
To include file in this way, the syntax is:
<%@ include file= ―Relative URL‖ %>
There are two consequences of the fact that the included file is inserted at page
translation time, not at request time as with jsp: include.
First, you include the actual file itself, unlike with jsp:include , where the server runs
the page and inserts its output. This approach means that the included file can contain
JSP constructs (such as field or method declarations) that affect the main page as a.
whole.
Second, if the included file changes, all the JSP files that use it need to be updated.
• Including Files at Request Time
As you studied, the include directive provides the facility to include documents that
contain JSP code into different pages. But this directive requires you to update the
modification date of the page whenever the included file changes, which is a
significant inconvenience.
5 Explain how SOAP and web services have opened up new options for E- Commerce K2
12
CO6: Create interactive and individual website that includes all web programming features
1 Create XML Document For The Students Details Using Xml With XSL K3
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='cgpa.xsl'?>
<class> 12
<student>
<name> ABC </name>
<id> 001 </id>
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
<branch> IT </branch>
<cgpa> 9 </cgpa>
</student>
<student>
<name> PQR </name>
<id> 004 </id>
<branch> Computer </branch>
<cgpa> 7 </cgpa>
</student>
<student>
<name> XYZ </name>
<id> 006 </id>
<branch> IT </branch>
<cgpa> 10 </cgpa>
</student>
</class>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Student list in descending order of their CGPA.</h2>
<table border="1">
<tr bgcolor="lightblue">
<th>ID</th>
<th>Name</th>
<th>Branch</th>
<th>CGPA</th>
</tr>
<xsl:for-each select="class/student">
<xsl:sort select="cgpa" order="descending" data-type="number"/>
<tr>
<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="branch"/></td>
<td><xsl:value-of select="cgpa"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
2 Explain structure of UDDI with necessary example. K2
UDDI is an XML-based standard for describing, publishing, and finding web services.
UDDI stands for Universal Description, Discovery, and Integration.
UDDI is a specification for a distributed registry of web services.
UDDI is a platform-independent, open framework.
12
UDDI can communicate via SOAP, CORBA, Java RMI Protocol.
UDDI uses Web Service Definition Language(WSDL) to describe interfaces to web services.
UDDI is seen with SOAP and WSDL as one of the three foundation standards of web
services.
UDDI is an open industry initiative, enabling businesses to discover each other and define
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
2) DOM parser is faster than SAX because it access whole XML document in memory.
3) SAX parser in Java is better suitable for large XML file than DOM Parser because it
12
doesn't require much memory.
4) DOM parser works on Document Object Model while SAX is an event based XML parser.
That’s all on the difference between SAX and DOM parsers in Java, now it’s up to you on
which XML parser you going to choose. I recommend using DOM parser over SAX parser if
XML file is small enough and go with SAX parser if you don’t know the size of XML files to
be processed or they are large
4 Elaborate on the SOAP Intermediaries, Actors, Design Patterns and Faults. K2
he Need for Intermediaries
SOAP intermediaries are applications that can process parts of a SOAP message as it travels
from its origination point to its final destination point. The route taken by a SOAP message,
including all intermediaries it passes through, is called the SOAP message path.
Securing message exchanges, particularly through untrustworthy domains—You could secure
SOAP messages by passing them through an intermediary that first encrypts them and then
digitally signs them. On the receiving side an intermediary would perform the inverse
operations: checking the digital signature and, if it's valid, decrypting the message.
12
Notarization/nonrepudiation—when the sender or receiver (or both) desires a third party to
make a record of an interaction, a notarizing intermediary is a likely solution. Instead of
sending the message directly to the receiver, the sender sends to the intermediary, who makes
a persistent copy of the request and then sends it to the service provider. The response
typically comes back via the intermediary as well, and then both parties are usually given a
token they can use to reference the transaction record in the future.
Providing message tracing facilities—Tracing allows the message recipient to find out the
path the message followed, complete with detailed timings of arrivals and departures to and
from intermediaries. This information is indispensable for tasks such as measuring quality of
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
<head>
<title>MANI.S</title>
<script type="JavaScript">
function aa()
{ msg=open("","DisplayWindow","height=200,width=456,status=yes,toolbar=yes
directories=no,menubar=yes,location=yes");
msg.document.write("<html><title> A NEW WINDOW</title><body><img
src='F:\PICTURES\vijay1024_020708.gif'><p><form><input type='BUTTON'
value='CLOSE'"+"onClick='self.close()'>"+"</form></body></html></p>");
}
</script>
</head>
<body bgcolor="BLUE">
<p><form>
<input type="button" name="BUTTON" value="CLICK" onClick="aa()">
</form>
<p>
</body>
</html>
2 Explain handling HTTP GET and HTTP POST methods in java script with suitable example 20 K4
program
public void processRequest(HttpServletRequest request) {
// null value for submit - user hit enter instead of clicking on
// "add" or "remove"
if (submit == null)
addItem(item);
if (submit.equals("add"))
addItem(item);
else if (submit.equals("remove"))
removeItem(item);
// reset at the end of the request
reset();
}
<html>
<head>
<title>carts</title>
</head>
<body bgcolor="white">
<font size = 5 color="#CC0000">
<form type=POST action=carts.jsp>
<BR>
Please enter item to add or remove:
<br>
Add Item:
<SELECT NAME="item">
<OPTION>Beavis & Butt-head Video collection
<OPTION>X-files movie
</SELECT>
<br> <br>
<INPUT TYPE=submit name="submit" value="add">
<INPUT TYPE=submit name="submit" value="remove">
</form></FONT></body></html>
CO3: Develop server side programming techniques to solve real time application.
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
1 Develop an socket program to send a set of sales data(use your own sales fingures) one by
one to the server. Write the corresponding server side program to calculate the commission
for each sales man and return the result to the client
public class DummyCart {
Vector v = new Vector();
String submit = null;
String item = null;
private void addItem(String name) {
v.addElement(name);
}
private void removeItem(String name) {
v.removeElement(name);
}
public void setItem(String name) {
item = name;
}
public void setSubmit(String s) {
submit = s;
}
public String[] getItems() {
String[] s = new String[v.size()];
v.copyInto(s);
return s;
}
public void processRequest(HttpServletRequest request) {
// null value for submit - user hit enter instead of clicking on
// "add" or "remove" 20 K4
if (submit == null)
addItem(item);
if (submit.equals("add"))
addItem(item);
else if (submit.equals("remove"))
removeItem(item);
// reset at the end of the request
reset();
}
// reset
private void reset() {
submit = null;
item = null;
}
}
HTMLFilter.java
package util;
public final class HTMLFilter {
public static String filter(String message) {
if (message == null)
return (null);
char content[] = new char[message.length()];
message.getChars(0, message.length(), content, 0);
StringBuffer result = new StringBuffer(content.length + 50);
for (int i = 0; i < content.length; i++) {
switch (content[i]) {
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
case '<':
result.append("<");
break;
case '>':
result.append(">");
break;
case '&':
result.append("&");
break;
case '"':
result.append(""");
break;
default:
result.append(content[i]);
}
}
return (result.toString());
}}
2 How can you use the servlet session tracking API to keep track of visitors as they move K4
around at your site?
public class DisplayBookSax extends DefaultHandler
{
static private Writer writerOut;
StringBuffer stringBuffer;
public static void main(String f[])
{
DefaultHandler d=new DisplayBookSax();
SAXParserFactory saxParserFactory=SAXParserFactory.newInstance();
try
{
writerOut=new OutputStreamWriter(System.out,"UTF8");
SAXParser Sax_Parser=saxParserFactory.newSAXParser();
Sax_Parser.parse(new File(f[0]),d);
}
catch(Throwable thr)
20
{}
}
public void startDocument()throws SAXException
{
IOHandler("<?xml version='1.0' encoding='UTF-8'?>");
newLine();
}
public void endDocument()throws SAXException
{
try
{
newLine();
writerOut.flush();
}
catch(Throwable thr)
{}
}
CO4: Apply database concept to create interactive web pages.
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
<h3>Login Form</h3>
<%
String profile_msg=(String)request.getAttribute("profile_msg");
if(profile_msg!=null){
out.print(profile_msg);
}
String login_msg=(String)request.getAttribute("login_msg");
if(login_msg!=null){
out.print(login_msg);
}
%>
<br/>
<form action="loginprocess.jsp" method="post">
Email:<input type="text" name="email"/><br/><br/>
Password:<input type="password" name="password"/><br/><br/>
<input type="submit" value="login"/>"
</form>
<%@page import="bean.LoginDao"%>
<jsp:useBean id="obj" class="bean.LoginBean"/>
<%
boolean status=LoginDao.validate(obj);
if(status){
out.println("You r successfully logged in");
session.setAttribute("session","TRUE");
}
else
{
out.print("Sorry, email or password error");
%>
<jsp:include page="index.jsp"></jsp:include>
<%
}
%>
2 Write the JSP code to create online order processing system 20 K3
<%@page import="bean.RegisterDao"%>
<jsp:useBean id="obj" class="bean.User"/>
<%
int status=RegisterDao.register(obj);
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
if(status>0)
out.print("You are successfully registered");
%>
package bean;
public class User {
private String uname,upass,uemail;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getUpass() {
return upass;
}
public void setUpass(String upass) {
this.upass = upass;
}
public String getUemail() {
return uemail;
}
public void setUemail(String uemail) {
this.uemail = uemail;
}
}
public static int register(User u){
int status=0;
try{
Connection con=ConnectionProvider.getCon();
PreparedStatement ps=con.prepareStatement("insert into user432 values(?,?,?)");
ps.setString(1,u.getUname());
ps.setString(2,u.getUemail());
ps.setString(3,u.getUpass());
status=ps.executeUpdate();
}catch(Exception e){}
return status;
}
}
CO5: Apply JSP concepts to solve real time applications
1 How is XML useful in extending the Enterprise? Elaborate on the XML Technology Family. 20 K3
Elements, Tags, Attributes, Entities, PCDATA, and CDATA
Elements Elements are the main building blocks of both XML and HTML documents.
Tags Tags are used to markup elements.
Attributes Attributes provide extra information about elements.
PCDATA PCDATA means parsed character data
CDATA CDATA also means character data. CDATA is text that will NOT be parsed by a
parser
Entities Entities as variables used to define common text. Entity references are references to
entities.
<!ELEMENT [element_name] ([names of allowed elements])>
eg: <!ELEMENT sno (#PCDATA)>
External DTD: <!DOCTYPE note SYSTEM "student.dtd">
where student.dtd is the name of the DTD file. The tags developed in the DTD can
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
XML Document for the Students Details and DTD with DSS
Student.css
student
{
background.color:#FFFABC;
width=100%;
}
record
{
display:block;
color:BLACK;
font.size:20pt;
}
sno
{
display:block;
color:GREEN;
font.size:15pt;
}
<?xml version="1.0"?>
<!ELEMENT students (student+)>
<!ELEMENT student (record,sno,sname,dob,address,m1,m2,m3)>
<!ELEMENT record (#PCDATA)>
<!ELEMENT sno (#PCDATA)>
<!ELEMENT sname (#PCDATA)>
<!ELEMENT dob (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT m1 (#PCDATA)>
<!ELEMENT m2 (#PCDATA)>
<!ELEMENT m3 (#PCDATA)>
student.xml
?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="student.css"?>
<!DOCTYPE student SYSTEM "student.dtd">
<students>
<student>
<record>RECORD 1</record>
<sno>01110901001</sno>
<sname>ARUN BALAJI</sname>
<dob>04/01/1983</dob>
<address>Trichy</address>
<m1>80</m1>
<m2>85</m2>
<m3>90</m3>
</student>
<student>
<record>RECORD 2</record>
<sno>01110901002</sno>
<sname>ARUNABARATH</sname>
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
<dob>04/02/1982</dob>
<address>Chennai</address>
<m1>90</m1>
<m2>80</m2>
<m3>95</m3>
</student>
</students>
2 Create XML document for the students with TD/Schema 20 K4
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body bgcolor="orange">
<center><h1>Anna University of Technology</h1>
<h2>Tiruchirapalli</h2>
M.E (Modular Based Credit Banking System)
<h3>Student Details</h3>
<table border="5" bgcolor="lightgreen">
<tr>
<th>Register Number</th>
<th>Name</th>
<th>Department</th>
<th>Contact Address</th>
<th>Contact Number</th>
</tr>
<xsl:for-each select="STUDENT/CD">
<tr>
<td><xsl:value-of select="REGISTERNO"/></td>
<td><xsl:value-of select="NAME"/></td>
<td><center><xsl:value-of select="DEPARTMENT"/></center></td>
<td><xsl:value-of select="CONTACTADDRESS"/></td>
<td><xsl:value-of select="CONTACTNUMBER"/></td>
</tr>
</xsl:for-each>
</table></center>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
CO6: Create interactive and individual website that includes all web programming features
1 Create a XML Parser to retrieve student details using DOM 20 K4
The XML DOM defines a standard for accessing and manipulating XML. The w3c document
object model is a platform neutral interfcae that allows progrmas and scripts to dynamically
access abd update the content, structure and style of a document. The XML DOM views an
XML document as a tree-structure. The tree structure is called a node-tree. All nodes can be
accessed through the tree. Their contents can be modified or deleted, and new elements can
be created. The terms parent, child, and sibling are used to describe the relationships. Parent
nodes have children. Children on the same level are called siblings (brothers or sisters).
In a node tree, the top node is called the root
1 Every node, except the root, has exactly one parent node
2 A node can have any number of children
E.G.S. PILLAY ENGINEERING COLLEGE
Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2017/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>