department of information technology web...
TRANSCRIPT
P.SARANYA,AP/IT 1
DEPARTMENT OF INFORMATION TECHNOLOGY
WEB TECHNOLOGY IMPORTANT QUESTIONS
UNIT I
WEB SERVICES
PART A
1. Define Internet ?
Network is an interconnection of systems to share data and information.
Internet is network of network or collection of heterogeneous networks.
2. What is the use of ip addresses and ports?
It is very difficult to remember the IP address of each and every node.
In order to avoid this problem domain names are used.
Example googl.com, rediff.com etc.
Ports
Ports are used in receiving and sending data to another server or client.
3. Mention the different internet address class and it’s range.
Internet addresses are assigned to different organizations by the Internet Assigned Numbers
Authority (IANA).
ISP – Internet Service Providers gives a block addresses.
Class C address block specifies the first 3 bytes of address, for example 199.1.32. This allows
room for 254 individual addresses from 199.1.32.1 to 199.1.32.254
Class B address specified only the first 2 bytes of the addresses .
There are also Class D and E addresses are used for IP multicast group.
4. Define Firewall.
The hardware and software that sits between the Internet and the local network, checking all the
data that comes and goes out is called ―firewalls‖. The security is provided using SSL(Secure Socket
Layer) in internet.
5. Define Proxy Servers
P.SARANYA,AP/IT 2
Proxy servers are related to firewalls prevents hosts on a network from making direct connections
to the outside world, a proxy server can act as a go-between. Thus a machine that is prevented from
connecting to the external network by a firewall would make a request for a web page from the local
proxy server instead of requesting the web page directly from the remote web server.
6. What is the use of HTTP protocol?
HTTP is a standard protocol that defines how a web client talks to a server and how data is
transferred from the server back to the client.
HTTP relies heavily on two other standards.
MIME (Multipurpose Internet Mail Extensions), HTML
7. What is the use of MIME?(Multipurpose Internet Mail Extension)
MIME is a way to encode different kinds of data, such as sound and text, to be transmitted over a
7-bit ASCII connection.
It also lets the recipient know what kind of data has been sent, so that it can be displayed properly.
MIME was originally designed to facilitate multimedia email and to provide an encoding that
could get binary data past the most train –damaged mail transfer programs.
MIME is an open standard for sending multipart, multimedia data through Internet email.
MIME was originally intended for email, it has become a widely used technique to describe a
file‘s contents so that client software can tell the difference between different kinds of data.
8. Define URL.
URL
Uniform Recourse Locator is a way to unambiguously identify the location of a resource on the
Internet.
URI Uniform Resource Identifier is a string of characters in a particular syntax that identifies a
resource.
Syntax
Scheme: scheme-specific-part
9. Explain about URN
There are 2 types of URLs.
URL – Unform Resource Locaters (is a pointer to a particular resource on the Internet at a
particular location.)
URNs – Uniform Resource Name (is a name for a particular resource but without reference to a
particular location)
P.SARANYA,AP/IT 3
Syntax of URN
urn:namespace:resource-name
namespace - is the name of a collection of certain kinds of resources maintained by some
authority.
resource-name – is the name of a resource within that collection.
10. Explain the elements of WWW.
Client & server
Web languages & protocols
Web pages
Home page
Web browsers
Web sites
11. What is Web Services?
Web service is a technology, a process, and a phenomenon. As a technology it is a set of protocols
that builds on the global connectivity made possible by SOAP and HTTP. As a process, it is an approach
to s/w discovery and connection over web. As a phenomenon, it‘s an industry wide realization.
12. What are the things available in Web Services?
Describing: Web services describe its functionality and attributes
Exposing: Web services register with a repository that contains a white pages holding basic
service-provider information, a yellow pages listing services by category, and a green pages
describing how to connect and use the services.
Being invoked: When a web service has been located, a remote application can invoke the
services.
Returning a response: When a service has been invoked, results are returned to the requesting
application.
13. What Qualifies as Web Services?
A Web service is anything that can define itself via an internet. The things that can be expressed
as web services:
1. Software Component or Application
2. A Movie review
3. A travel package
14. List out the advantage of Web services technology?
P.SARANYA,AP/IT 4
1. Decide on the service it wants to provide
2. Pick a registry for uploading it‘s information
3. Decide how to list its service at the registry
4. Define explicitly how users can connect to its service
15. What are the major aspects of Web service technologies?
A service provider provides an interface for software that can carry out a specified set of tasks.
A service requester discovers and invokes a software service to provide business solution.
A repository or broker manages and publishes the service. Service providers publish their services
with the broker, and requests access those services by creating bindings to the service provider.
16. List out the key technologies?
UDDI is a protocol for describing Web services components that allows businesses to register
with an Internet directory and advertise their services.
WSDL is the proposed standard for describing a Web services. WSDL is built around an XML-
based service Interface Definition Language that defines both the service interface and
implementation details.
SOAP is a protocol for communicating with a UDDI service.
17. What is UDDI?
UDDI means Universal Description, Discovery and Integration. UDDI is a protocol for
communicating with registries. The core of UDDI is the UDDI Business Registry, a global, pubic, online
directory.
18. What are Web Services Registry Directories?
White Pages: holding basic service-provider information
Yellow Pages: listing services by category
Green Pages: describing how to connect and use the services.
19. What is WSDL?
WSDL is Web Service, Definition Language. WSDL is the piece of Web services framework that
describes how to connect to web service providers. The WSDL specification supports the building of web
based computing services that target computer programs rather than human users.
20. What are the risks in Web Services?
Maturity: Different implementation may not work together.
Security: SOAP messages on port 80 bypass firewalls. So network administrator has to implement
necessary security to prevent attacks.
P.SARANYA,AP/IT 5
Transaction: Transaction must be specified outside the web services framework such as .NET or
J2EE.
Configuration Management: Change management is not addressed.
21. What is SOAP?
SOAP-Simple Object Access Protocol
Soap gives set of rules for moving data directly to the receipient or through and intermediate
message queue.Soap uses common web protocols like HTTP,FTP and SMTP to enable
communication across the web.
22. What is SOA?
SOA is an architectural style for building software applications that use services available in a
network such as the web. It promotes loose coupling between software components so that they can be
reused.
23. What are the web service roles?
There are three major roles within the web service architecture:
Service provider:
This is the provider of the web service. The service provider implements the service and makes it
available on the Internet.
Service requestor
This is any consumer of the web service. The requestor utilizes an existing web service by
opening a network connection and sending an XML request.
Service registry
This is a logically centralized directory of services. The registry provides a central place where
developers can publish new services or find existing ones. It therefore serves as a centralized
clearinghouse for companies and their services.
24. Define three tier architecture.
A special type of client/server architecture consisting of three well-defined and separate
processes, each running on a different platform:
1. The user interface, which runs on the user's computer (the client).
2. The functional modules that actually process data. This middle tier runs on a server and is often called
the application server.
3. A database management system (DBMS) that stores the data required by the middle tier. This tier runs
on a second server called the database server.
P.SARANYA,AP/IT 6
25. What are the layers of standards in the technology stack of the SOA?
The Web Services/SOA Technology Stack
PART B
1. Explain about Web Services Technologies?
Web Services Technologies
The Web Service Architechture
Key Technologies
UDDI
WSDL
SOAP
2. Explain about SOAP message, design patterns, faults, and SOAP with attachments.
SOAP Message Structure
SOAP consists of 3 parts
Explain SOAP envelop
Explain SOAP header
Explain SOAP body
SOAP FAULTS
3. Explain WebServices.
Webservices is both a process and set of protocols for finding and connecting to Software
exposed as services over the Web.
Webservices builds on a SOAP foundation & facilitates software interaction.
Webservices Architecture:
Webservices=repository+client+provider.
Key Technologies.
P.SARANYA,AP/IT 7
UDDI-Universal Description, Discovery and integration.
WSDL – Web services Description language.
SOAP-Simple Object access protocol.
Web Services Risks:
Maturity
Security
Transactions
Configuration Management.
4. Explain in detail about the Service Oriented roles & its Architecture.
SOA
Definition
Characteristics of SOA
Diagram
Service Oriented roles
Service provider
Creates services and publishes to registry
Service broker
Holds information on how to find and ―bind‖ to a (web) service
Service requester
Searches the registry, finds services, and ―invokes‖ them after
―binding‖
SOA protocols
UDDI
WSDL
SOAP
LDAP
5. Explain in detail about Web service architecture
Web Services Paradigm
Web Services – Protocols(explanation)
Web Services Protocol Stack(Diagram)
P.SARANYA,AP/IT 8
Web Services Process Architecture(explanation)
Web Services Process Architecture(Diagram)
6. Explain in detail about three tier architecture & its usage in web development.
The 3-Tier architecture has the following three tiers.
Presentation Tier
Logic Tier / Business Logic Tier / Transaction Tier
Data Tier
Diagram
Example
Web development usage
P.SARANYA,AP/IT 9
UNIT II
XML
PART A
1. What is XML?
Extensible Markup Language (XML) is the universal language for data on the Web
XML is a technology which allows us to create our own markup language.
XML documents are universally accepted as a standard way of representing information in
platform and language independent manner.
XML is universal standard for information interchange.
XML documents can be created in any language and can be used in any language.
2. What are the three key design elements that by omission contribute XML’s success?
No display is assumed.
There is no built-in data typing.
No transport is assumed.XML specification makes no aassumption about how XML is transported
across the Internet.
3. XML History
XML is a meta language defined by world wide web consortium (W3C) and standardized in
1998.XML has given rise to numerous vertical industry vocabularies in support of B2B e-commerce,
horizontal vocabularies that provide service to a wide range of industries and XML protocols that have
used XML‘s simple power of combination to open up new possibilities for doing distributed computing.
4. What are the advantages of xml?
xml files are human readable.
Widespread industry support exists for xml due to its inexpensiveness and convenience in usage.
It provides a way of creating domain specific vocabulary.
It allows data interchange between different computers.
It provides user selected view of data.
5. What is Electronic Data Interchange(EDI)?
EDI is often used as the replacement for business communication through conventional business
documents such as purchase orders,request for quotations,invoice and shipping notices.This kind of
exchange takesplace between trading partners.Inorder to interchange data using EDI to trading partners
must be agreed upon a common format.
6. What is W3c (World Wide Web)Consortium?
P.SARANYA,AP/IT 10
W3c is responsible for the development of web specifications that describe communication
protocols and technologies for the web .XML was defined by w3c to ensure that structured data is
uniform and independent of vendors of applications.W3c has laid down certain rules that meet to be
followed by the all xml applications.Some of these rules are:
XML must be directly usable over the internet.
XMl must support the wide variety of applications.
XML must be SGML.
XML documents must be human legible and clear.
XML design must be formal and concise.
7. List out the reasons for not using attributes to store data.
Attributes cannot contain multiple values,while elements can have multiple subelements.
Attributes are not easily expandable to account for future changes.
Attributes are more difficult than elements to manipulate with programs.
Attributes values are not easy to check against a document type definition.
8. What are all the xml language basics?
Elements
Attributes
Entities
9. What is an entity? Give Example.
Entities are used to create substitution strings within a xml document
Example:
Xml and data evaluation can be defined with short string using entity declaration in DTD
<!ENTITY xdr ―xml and data revolution‖>.
10. What is the role of xml?
XML is the set of guidelines foe describing structured data in plaintext rather than binary
representation within the short period, time. XML has been widely used as language for variety of
application ranging from vertical industry vocabularies to horizontal industry application to protocol.
11. What is XPath?
XPath is used to navigate XML tree structures. XPath gets its name from its use of path notation
to navigate through the hierarchical tree structure of an XML document. XPath allows for the section of
the node or group of node through the use of a compact, on XML syntax. It is an important XML
P.SARANYA,AP/IT 11
technology due to its role in providing a common syntax and semantics for functionality in both XSLT
and Xpointer.
12. What are the Element Naming Rules used in XML?
Names can contain letters, numbers and other characters.
Names must not begin with number or punctuation.
Names must not start with the string "xml" in any upper or lowercase form.
Names must not contain spaces
13. What are the advantages of schema over DTD?
It provides more control over the type of data that can be assigned to elements and as compared to
DTD.
DTD dose not enable you to define your own customized datatypes.But schema definition enables
you to create your own datatypes.
It also allows to specify restrictions on data.
The syntax for defining DTD is different from the syntax used for creating an xml document .But
the syntax for defining XSD is the same as the syntax of an xml document.
14. What are the datatypes in an xml schema?
Primitive
Derived
Atomic
List
Union
15. What is DOM? What are the different levels of DOM?
DOM is a W3C supported standard programming interface(API)that provides a platform and
neutral interface to allow developers to programmatically access and modify content and structure of tree
structured documents such as HTML or XML.
16. What are the drawbacks of CSS?
The browser decides how to display elements that the stylesheet doesn‘t describe.
As browser implements CSS, some implementations may not always be consistent.
17. Write any two differences between XSLT and CSS?
CSS
Simple to use,and is suitable for simple document.
Cannot reorder,add,delete or perform operations on elements
P.SARANYA,AP/IT 12
XSLT
It is complex to use.
Can reorder,add,delete the elements because it is aware of the structure of an XML document.
18. What are the different XSLT elements?
Stylesheet
Value-of
For-each
Sort
Text
19. What is XQuery?
XQuery is a W3C initiative to define a standard set of constructs for querying and searching XML
documents. XQuery brings database query processing to XML.
20. What are complex types?
Complex types are an important aspects of xml schema that allow application developers to
define application-specific datatypes that can be checked by programs that check XML document for
validity. XML schema divides complex types into two categories: those with simple content & those with
complex content.
21. What all are the presentation technologies?
CSS - cascading syle sheets
XSL - provides users with ability to describe how xml data & document are to be formated.
Xforms - it is a GUI toolkit for creating user interfaces & delivering the results in XML.
Xhtml - it is used yo replace HTML with more flexable approach to display webcontent.
VoiceXML - it is an emerging standard for speech enabled application.
22. What are all the Transformation techniques?
XSLT - it is an XML- based languages used to transform XML documents into others format
such as HTML for web display.
XLINK - highlighting that element or taking the user directly to that point in the document.
XPATH - xpath gets its name from its use of a payh notation to navigate through the hierarchical
tree structure of an XML document
XQUERY - it is w3c initiative to define a standard set of constructs for querying & searching
XML document.
23. What is valid xml document?
P.SARANYA,AP/IT 13
If an xml document conforms to the rule set out by a DTD the xml is said to be valid with the respect to
that DTD.
24.What is the difference between XML and HTML?
XML is no way clashes with HTML, since they are for two different purposes.
HTML XML
HTML is for displaying purpose. whereas XML is for data representation.
HTML is used to mark up text so it can be
displayed to users.
XML is used to mark up data so it can be
processed by computers.
HTML describes both structure (e.g. <p>, <h2>,
<em>) and appearance (e.g. <br>, <font>, <i>) XML describes only content, or ―meaning‖
HTML uses a fixed, unchangeable set of tags In XML, you make up your own tags
25. What are the benefits of XML?
There are many benefits of using XML on the Web :
Simplicity- Information coded in XML is easy to read and understand, plus it can be processed easily by
computers.
Openness- XML is a W3C standard, endorsed by software industry market leaders.
Extensibility - There is no fixed set of tags. New tags can be created as they are needed.
Self-description- In traditional databases, data records require schemas set up by the database
administrator. XML documents can be stored without such definitions, because they contain meta data in
the form of tags and attributes.
Contains machine-readable context information- Tags, attributes and element structure provide
context information that can be used to interpret the meaning of content, opening up new possibilities for
highly efficient search engines, intelligent data mining, agents, etc.
Separates content from presentation- XML tags describe meaning not presentation. The motto of
HTML is: "I know how it looks", whereas the motto of XML is: "I know what it means, and you tell me
how it should look." The look and feel of an XML document can be controlled by XSL style sheets,
allowing the look of a document to be changed without touching the content of the document. Multiple
views or presentations of the same content are easily rendered.
P.SARANYA,AP/IT 14
Supports multilingual documents and Unicode-This is important for the internationalization of
applications.
Facilitates the comparison and aggregation of data - The tree structure of XML documents allows
documents to be compared and aggregated efficiently element by element.
Can embed multiple data types - XML documents can contain any possible data type - from
multimedia data (image, sound, video) to active components (Java applets, ActiveX).
Can embed existing data - Mapping existing data structures like file systems or relational databases to
XML is simple. XML supports multiple data formats and can cover all existing data structures and .
Provides a 'one-server view' for distributed data - XML documents can consist of nested elements that
are distributed over multiple remote servers. XML is currently the most sophisticated format for
distributed data - the World Wide Web can be seen as one huge XML database.
26. What is a well-formed XML document?
If a document is syntactically correct it can be called as well-formed XML documents. A
well-formed document conforms to XML's basic rules of syntax:
Every open tag must be closed.
The open tag must exactly match the closing tag: XML is case-sensitive.
\All elements must be embedded within a single root element.
Child tags must be closed before parent tags.
A well-formed document has correct XML tag syntax, but the elements might be invalid for
the specified document type.
27. What is a valid XML document?
If a document is structurally correct then it can be called as valid XML documents. A valid document
conforms to the predefined rules of a specific type of document:
These rules can be written by the author of the XML document or by someone else.
The rules determine the type of data that each part of a document can contain.
28. How does the XML structure is defined?
XML document will have a structure which has to be defined before we can create the documents
and work with them. The structural rules can be defined using many available technologies, but the
following are popular way of doing so-
Document Type Definition (DTD)
Schema
P.SARANYA,AP/IT 15
29. What is the structure of XML document ?
30. What is DTD?
A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines
rules for a specific type of document, including:
Names of elements, and how and where they can be used
The order of elements
Proper nesting and containment of elements
Element attributes
To apply a DTD to an XML document, you can:
Include the DTD's element definitions within the XML document itself.
Provide the DTD as a separate file, whose name you reference in the XML document.
31.What is XML Schema?
An XML Schema describes the structure of an XML instance document by defining what each element
must or may contain.XML Schema is expressed in the form of a separate XML file.
XML Schema provides much more control on element and attribute datatypes.
Some datatypes are predefined and new ones can be created.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="test">
<xsd:complexType>
P.SARANYA,AP/IT 16
32.What are differences between DTDs and Schema?
Schema DTD
Schema document is an XML document i.e., the
structure of an XML document is specified by
another XML document.
DTDs follow SGML syntax.
Schema supports variety of dataTypes similar to
programming language. In DTD everything is treated as text.
In Schema, It is possible to inherit and create
relationship among elements.
This is not possible in DTD without invalidating
existing documents.
In Schema, It is possible to group elements and
attributes so that they can be treated as single
logical unit.
Grouping of elements and attributes is not possible
in DTD.
In Schemas, it is possible to specify an upper limit It is not possible to specify an upper limit of an
P.SARANYA,AP/IT 17
for the number of occurrences of an element element in DTDs
33.What is a Complex Element?
A complex element is an XML element that contains other elements and/or attributes.
There are four kinds of complex elements:
empty elements
elements that contain only other elements
elements that contain only text
elements that contain both other elements and text
34.What is a Simple Element?
A simple element is an XML element that can contain only text.
A simple element cannot have attributes
A simple element cannot contain other elements
A simple element cannot be empty
However, the text can be of many different types, and may have various restrictions applied to it
35.What are namespaces? Why are they important?
A simple element is an XML element that can contain only text.
Namespaces are a simple and straightforward way to distinguish names used in XML documents,
no matter where they come from.
XML namespaces are used for providing uniquely named elements and attributes in an XML
instance
They allow developers to qualify uniquely the element names and relationships and make these
names recognizable, to avoid name collisions on elements that have the same name but are
defined in different vocabularies.
They allow tags from multiple namespaces to be mixed, which is essential if data is coming from
multiple sources.
Example: a bookstore may define the <TITLE> tag to mean the title of a book, contained only
within the <BOOK> element. A directory of people, however, might define <TITLE> to indicate
a person's position, for instance: <TITLE>President</TITLE>. Namespaces help define this
distinction clearly.
36. What are the ways to use namespaces?
P.SARANYA,AP/IT 18
There are two ways to use namespaces:
Declare a default namespace
Associate a prefix with a namespace, then use the prefix in the XML to refer to the namespace
37.What is XML parser?
An XML parser is a piece of software which can do following:
Check for well-formedness
Validate the document
Allows us to read, create or modify existing XML documents
38.What is DOM?
The Document Object Model (DOM) is a platform and language-independent standard object
model for representing XML and related formats. DOM is standard API which is not specific to any
programming language. DOM represents an XML document as a tree model. The tree model makes the
XML document hierarchal by nature. Each and every construct of the XML document is represented as a
node in the tree.
39.What is a CDATA section in XML?
CDATA Sections are used to escape blocks of text containing characters which would otherwise
be recognized as markup. All tags and entity references are ignored by an XML processor that treats them
just like any character data. CDATA blocks have been provided as a convenience measure when you
want to include large blocks of special characters as character data, but you do not want to have to use
entity references all the time.
40.What is XSL?
eXtensible Stylesheet Language(XSL) deals with most displaying the contents of XML
documents.XSL consists of three parts:
XSLT - a language for transforming XML documents
XPath - a language for navigating in XML documents
XSL-FO - a language for formatting XML documents
41. How is XSL different from Cascading Style Sheets? Why is a new Stylesheet language needed?
XSL is compatible with CSS and is designed to handle the new capabilities of XML that CSS
can't handle. XSL is derived from Document Style Semantics and Specification Language (DSSSL), a
complex Stylesheet language with roots in the SGML community. The syntax of XSL is quite different
from CSS, which could be used to display simple XML data but isn't general enough to handle all the
possibilities generated by XML. XSL adds the capability to handle these possibilities. For instance, CSS
P.SARANYA,AP/IT 19
cannot add new items or generated text (for instance, to assign a purchase order number) or add a footer
(such as an order confirmation). XSL allows for these capabilities.
42.What is XSLT?
eXtensible Stylesheet Language Transformation (XSLT) deals with transformation of one XML
document into XHTML documents or to other XML documents. XSLT uses XPath for traversing an
XML document and arriving at a particular node.
43. What is the role of XSL transformer?
An XSL transformer will transform in the following way:
The source tree is obtained by parsing in a normal XML style
The transformation is now applied to the source with the help of information available in
Stylesheet.
44. What is XSL template?
Template specifies transformation rules. A Stylesheet document can be made up of at least one
template, which acts as an entry point. Every template uniquely identifies a particular node in the source
tree.
45.What is XPath?
XPath is an expression language used for addressing parts of an XML document. XPath is used
to navigate through elements and attributes in an XML document.
46. What is the structure of XSLT?
47.What is XSL-FO?
XSL-FO deals with formatting XML data. This can be used for generating output in a particular
format like XML to PDF, XML to DOC, etc.
48.How XSL-FO Works (or) How would you produce PDF output using XSL’s?
P.SARANYA,AP/IT 20
PART B
1. Explain the Roles and Advantages of XML
XML definition
Roles
Advantages
2. Explain briefly XML:The Three Revolutions
The three revolutions are,
Data Revolution
Architecture Revolution
Software Revolution
4. Explain XML & DTD.
A DTD is used to define the structure of an XML document.A DTD may be used by both sender
and receiver of XML.Senders used to create Xml.Receiver used to compare the received document
against the dtd. A dtd can be declared in two ways.
P.SARANYA,AP/IT 21
1. Internal DTD
2. External DTD
Defining elements, attributes & entities in dtd
Possible attributes type
Default attributes values
Example
5. Explain the Building blocks of an XML Document.
XML Fundamentals
Elements
Element Naming Rule
Attributes
Entities
CDATA
6. Explain briefly xml Transformation?
Xml is supported by several technologies that allow xml to be manipulated and modifies in
various ways. These technologies include
XSLT
XLink
XPath
XQuery
7. Short notes on XML Namespaces?
Namespace Declarations
Namespace Abbrevations
8. How to transform XML documents to other forms
JAXP
The SAX API
The DOM API
XML Namespaces
Transforming a DOM Tree to an XML Document
Transforming an XML Document to an HTML Document
XSL Programming
XSL component view
P.SARANYA,AP/IT 22
XSLT Input Document View
9. Write short notes on CSS.
Features
Core Syntax
At-Rules
CSS1 Selectors
10. Dicuss the text properties of CSS with Suitable Example.
CSS Font Families
Font Family
Font Style
Font Size
Set Font Size With Pixels
Set Font Size With Em
All CSS Font Properties
Text Formatting and color
All CSS Text Properties
11. Explain in detail about Electronic Data Interchange.
Electronic Data Interchange is the computer-to-computer exchange of business data and
documents between companies using standard formats recognized both nationally and
internationally.
EDI Standards
EDI Processes
Outbound Process
Inbound Process
The EDI file structure
EDIFACT
EDI message
EDI Mapping
EDI Message structure
EDI Electronic Enveloping
P.SARANYA,AP/IT 23
UNIT III
JSP AND SERVLET
PART A
1. What is the difference between JSP and Servlets ?
JSP is used mainly for presentation only. A JSP can only be HttpServlet that means the only
supported protocol in JSP is HTTP. But a servlet can support any protocol like HTTP, FTP, SMTP etc.
2. What is difference between custom JSP tags and beans?
Custom JSP tag is a tag you defined. You define how a tag, its attributes and its body are
interpreted, and then group your tags into collections called tag libraries that can be used in any number
of JSP files. To use custom JSP tags, you need to define three separate components: the tag handler class
that defines the tag‘s behavior ,the tag library descriptor file that maps the XML element names to the tag
implementations and the JSP file that uses the tag library.
JavaBeans are Java utility classes you defined. Beans have a standard format for Java classes.
You use tags Custom tags and beans accomplish the same goals — encapsulating complex behavior into
simple and accessible forms. There are several differences:
Custom tags can manipulate JSP content; beans cannot. Complex operations can be reduced to a
significantly simpler form with custom tags than with beans. Custom tags require quite a bit more work
to set up than do beans. Custom tags usually define relatively self-contained behavior, whereas beans are
often defined in one servlet and used in a different servlet or JSP page. Custom tags are available only in
JSP 1.1 and later, but beans can be used in all JSP 1.x versions.
3. What are the different ways for session tracking?
Cookies
URL rewriting
HttpSession
Hidden form fields
4. What mechanisms are used by a Servlet Container to maintain session information?
Cookies, URL rewriting, and HTTPS protocol information are used to maintain session
information
5. Difference between GET and POST
In GET your entire form submission can be encapsulated in one URL, like a hyperlink. query
length is limited to 255 characters, not secure, faster, quick and easy. The data is submitted as part of
URL.
P.SARANYA,AP/IT 24
In POST data is submitted inside body of the HTTP request. The data is not visible on the URL
and it is more secure.
6. What is session?
The session is an object used by a servlet to track a user‘s interaction with a Web application
across multiple HTTP requests. The session is stored on the server.
7. What is servlet mapping?
The servlet mapping defines an association between a URL pattern and a servlet. The mapping is
used to map requests to Servlets.
8. What is servlet context ?
The servlet context is an object that contains a information about the Web application and
container. Using the context, a servlet can log events, obtain URL references to resources, and set and
store attributes that other servlets in the context can use.
9. What is a servlet ?
servlet is a java program that runs inside a web container.
10. Can we use the constructor, instead of init(), to initialize servlet?
Yes. But you will not get the servlet specific things from constructor. The original reason for
init() was that ancient versions of Java couldn‘t dynamically invoke constructors with arguments, so there
was no way to give the constructor a ServletConfig. That no longer applies, but servlet containers still
will only call your no-arg constructor. So you won‘t have access to a ServletConfig or ServletContext.
11. How many JSP scripting elements are there and what are they?
There are three scripting language elements: declarations, scriptlets, expressions.
12. How do I include static files within a JSP page?
Static resources should always be included using the JSP include directive. This way, the
inclusion is performed just once during the translation phase.
13. How can I implement a thread-safe JSP page?
You can make your JSPs thread-safe adding the directive <%@ page isThreadSafe=‖false‖ % >
within your JSP page.
14. What is the difference in using request.getRequestDispatcher() and
context.getRequestDispatcher()?
In request.getRequestDispatcher(path) in order to create it we need to give the relative path of the
resource. But in resourcecontext.getRequestDispatcher(path) in order to create it we need to give the
absolute path of the resource.
P.SARANYA,AP/IT 25
15. What are the lifecycle of JSP?
When presented with JSP page the JSP engine does the following 7 phases.
Page translation: -page is parsed, and a java file which is a servlet is created.
Page compilation: page is compiled into a class file
Page loading : This class file is loaded.
Create an instance :- Instance of servlet is created
jspInit() method is called
jspService is called to handle service calls
jspDestroy is called to destroy it when the servlet is not required.
16. What are context initialization parameters?
Context initialization parameters are specified by the <context-param> in the web.xml file, these
are initialization parameter for the whole application.
17. What is a Expression?
Expressions are act as place holders for language expression, expression is evaluated each time
the page is accessed. This will be included in the service method of the generated servlet.
18. What is a Declaration?
It declares one or more variables or methods for use later in the JSP source file. A declaration
must contain at least one complete declarative statement. You can declare any number of variables or
methods within one declaration tag, as long as semicolons separate them. The declaration must be valid
in the scripting language used in the JSP file. This will be included in the declaration section of the
generated servlet.
19. What is a Scriptlet?
A scriptlet can contain any number of language statements, variable or expressions that are valid
in the page scripting language. Within scriptlet tags, you can declare variables to use later in the file,
write expressions valid in the page scripting language, use any of the JSP implicit objects or any object
declared with a <jsp:useBean>. Generally a scriptlet can contain any java code that are valid inside a
normal java method. This will become the part of generated servlet‘s service method.
20. What are the advantages of JSP over Servlet?
JSP is a serverside technology to make content generation a simple appear.The advantage of JSP
is that they are document-centric. Servlets, on the other hand, look and act like programs. A Java Server
Page can contain Java program fragments that instantiate and execute Java classes, but these occur inside
an HTML template file and are primarily used to generate dynamic content. Some of the JSP
P.SARANYA,AP/IT 26
functionality can be achieved on the client, using JavaScript. The power of JSP is that it is server-based
and provides a framework for Web application development.
21. What is the life-cycle of JSP?
When a request is mapped to a JSP page for the first time, it translates the JSP page into a servlet
class and compiles the class. It is this servlet that services the client requests.
A JSP page has seven phases in its lifecycle, as listed below in the sequence of occurrence:
Translation
Compilation
Loading the class
Instantiating the class
jspInit() invocation
_jspService() invocation
jspDestroy() invocation
22. What is the jspInit() method?
The jspInit() method of the javax.servlet.jsp.JspPage interface is similar to the init() method of
servlets. This method is invoked by the container only once when a JSP page is initialized. It can be
overridden by a page author to initialize resources such as database and network connections, and to
allow a JSP page to read persistent configuration data.
23. What is the _jspService() method?
The _jspService() method of the javax.servlet.jsp.HttpJspPage interface is invoked every time a
new request comes to a JSP page. This method takes the HttpServletRequest and HttpServletResponse
objects as its arguments. A page author cannot override this method, as its implementation is provided by
the container.
24. What is the jspDestroy() method?
The jspDestroy() method of the javax.servlet.jsp.JspPage interface is invoked by the container
when a JSP page is about to be destroyed. This method is similar to the destroy() method of servlets. It
can be overridden by a page author to perform any cleanup operation such as closing a database
connection.
25. What JSP lifecycle methods can I override?
You cannot override the _jspService() method within a JSP page. You can however, override the
jspInit() and jspDestroy() methods within a JSP page. jspInit() can be useful for allocating resources like
P.SARANYA,AP/IT 27
database connections, network connections, and so forth for the JSP page. It is good programming
practice to free any allocated resources within jspDestroy().
26. How can I override the jspInit() and jspDestroy() methods within a JSP page?
The jspInit() and jspDestroy() methods are each executed just once during the lifecycle of a JSP
page and are typically declared as JSP declarations:
<%!
public void jspInit() { . . .
}
%>
<%!
public void jspDestroy() { . . .
}
%>
27. What are implicit objects in JSP?
Implicit objects in JSP are the Java objects that the JSP Container makes available to developers
in each page. These objects need not be declared or instantiated by the JSP author. They are
automatically instantiated by the container and are accessed using standard variables; hence, they are
called implicit objects.The implicit objects available in JSP are as follows:
request
response
pageContext
session
application
out
config
page
exception
The implicit objects are parsed by the container and inserted into the generated servlet code.
They are available only within the jspService method and not in any declaration.
28. What are JSP directives?
JSP directives are messages for the JSP engine. i.e., JSP directives serve as a
message from a JSP page to the JSP container and control the processing of the entire page
They are used to set global values such as a class declaration, method
implementation, output content type, etc.
They do not produce any output to the client.
Directives are always enclosed within <%@ ….. %> tag.
Ex: page directive, include directive, etc.
29. What is page directive?
P.SARANYA,AP/IT 28
A page directive is to inform the JSP engine about the headers or facilities that page should
get from the environment.
Typically, the page directive is found at the top of almost all of our JSP pages.
There can be any number of page directives within a JSP page (although the attribute –
value pair must be unique).
The syntax of the include directive is: <%@ page attribute="value">
Example:<%@ include file="header.jsp" %>
30. What are the different types of JSP tags?
The different types of JSP tags are as follows:
31. What are the attributes of page directive?
There are thirteen attributes defined for a page directive of which the important attributes
are as follows:
import: It specifies the packages that are to be imported.
session: It specifies whether a session data is available to the JSP page.
P.SARANYA,AP/IT 29
contentType: It allows a user to set the content-type for a page.
isELIgnored: It specifies whether the EL expressions are ignored when a JSP is translated
to a servlet.
32. What is the include directive?
The include directive is used to statically insert the contents of a resource into the current
JSP.
This enables a user to reuse the code without duplicating it, and includes the contents of the
specified file at the translation time.
The syntax of the include directive is as follows:
<%@ include file = "FileName" %>
This directive has only one attribute called file that specifies the name of the file to be
included.
33. What are the JSP standard actions?
The JSP standard actions affect the overall runtime behavior of a JSP page and also the
response sent back to the client.
They can be used to include a file at the request time, to find or instantiate a JavaBean, to
forward a request to a new page, to generate a browser-specific code, etc.
Ex: include, forward, useBean,etc. object
34. What are the standard actions available in JSP?
The standard actions available in JSP are as follows:
<jsp:include>: It includes a response from a servlet or a JSP page into the current page. It
differs from an include directive in that it includes a resource at request processing time,
whereas the include directive includes a resource at translation time.
<jsp:forward>: It forwards a response from a servlet or a JSP page to another page.
<jsp:useBean>: It makes a JavaBean available to a page and instantiates the bean.
<jsp:setProperty>: It sets the properties for a JavaBean.
<jsp:getProperty>: It gets the value of a property from a JavaBean component and adds it
to the response.
<jsp:param>: It is used in conjunction with <jsp:forward>;, <jsp:, or plugin>; to add a
parameter to a request. These parameters are provided using the name-value pairs.
<jsp:plugin>: It is used to include a Java applet or a JavaBean in the current JSP page.
P.SARANYA,AP/IT 30
35. What is the <jsp:useBean> standard action?
The <jsp:useBean> standard action is used to locate an existing JavaBean or to create a
JavaBean if it does not exist. It has attributes to identify the object instance, to specify the lifetime
of the bean, and to specify the fully qualified classpath and type.
36. What are the scopes available in <jsp:useBean>?
The scopes available in <jsp:useBean> are as follows:
page scope:: It specifies that the object will be available for the entire JSP page but not
outside the page.
request scope: It specifies that the object will be associated with a particular request and
exist as long as the request exists.
application scope: It specifies that the object will be available throughout the entire Web
application but not outside the application.
session scope: It specifies that the object will be available throughout the session with a
particular client.
37. What is the <jsp:forward> standard action?
The <jsp:forward> standard action forwards a response from a servlet or a JSP page to
another page.
The execution of the current page is stopped and control is transferred to the forwarded
page.
The syntax of the <jsp:forward> standard action is :
<jsp:forward page="/targetPage" />
Here, targetPage can be a JSP page, an HTML page, or a servlet within the same context.
If anything is written to the output stream that is not buffered before <jsp:forward>, an
IllegalStateException will be thrown.
38. What is the <jsp:include> standard action?
The <jsp:include> standard action enables the current JSP page to include a static or a
dynamic resource at runtime. In contrast to the include directive, the include action is used for
resources that change frequently. The resource to be included must be in the same context.The
syntax of the <jsp:include> standard action is as follows:
<jsp:include page="targetPage" flush="true"/>
39. What is the difference between include directive and include action?
P.SARANYA,AP/IT 31
Include directive Include action
The include directive, includes the content of
the specified file during the translation phase–
when the page is converted to a servlet.
The include action, includes the response
generated by executing the specified page (a JSP
page or a servlet) during the request processing
phase–when the page is requested by a user.
The include directive is used to statically insert
the contents of a resource into the current JSP.
The include standard action enables the current
JSP page to include a static or a dynamic
resource at runtime.
Use the include directive if the file changes
rarely. It‘s the fastest mechanism.
Use the include action only for content that
changes often, and if which page to include
cannot be decided until the main page is
requested.
40. What are scripting elements?
JSP scripting elements let you insert Java code into the servlet that will be generated from
the current JSP page. There are three forms:
Expressions of the form <%= expression %> that are evaluated and inserted into the output,
Scriptlets of the form <% code %> that are inserted into the servlet's service method,
Declarations of the form <%! code %> that are inserted into the body of the servlet class,
outside of any existing methods.
41. What is a scriptlet?
A scriptlet contains Java code that is executed every time a JSP is invoked. When a JSP is
translated to a servlet, the scriptlet code goes into the service() method. Hence, methods and
variables written in scriptlets are local to the service() method. A scriptlet is written between the
<% and %> tags and is executed by the container at request processing time.
42. What are JSP declarations?
As the name implies, JSP declarations are used to declare class variables and methods in a
JSP page. They are initialized when the class is initialized. Anything defined in a declaration is
P.SARANYA,AP/IT 32
available for the whole JSP page. A declaration block is enclosed between the <%! and %> tags. A
declaration is not included in the service() method when a JSP is translated to a servlet.
43. What is a JSP expression?
A JSP expression is used to write an output without using the out.print statement. It can be
said as a shorthand representation for scriptlets. An expression is written between the <%= and
%> tags. It is not required to end the expression with a semicolon, as it implicitly adds a semicolon
to all the expressions within the expression tags.
44. How is scripting disabled?
Scripting is disabled by setting the scripting-invalid element of the deployment descriptor to
true. It is a subelement of jsp-property-group. Its valid values are true and false. The syntax for
disabling scripting is as follows:
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
Servlet:
45. What is the Servlet?
A 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.
46. What are the uses of Servlet?
Typical uses for HTTP Servlets include:
Processing and/or storing data submitted by an HTML form.
Providing dynamic content, e.g. returning the results of a database query to the client.
A Servlet can handle multiple request concurrently and be used to develop high
performance system
Managing state information on top of the stateless HTTP, e.g. for an online shopping cart
system which manages shopping carts for many concurrent customers and maps every
request to the right customer.
47. What are the advantages of Servlet over CGI?
Servlets have several advantages over CGI:
P.SARANYA,AP/IT 33
A Servlet does not run in a separate process. This removes the overhead of creating a new
process for each request.
A Servlet stays in memory between requests. A CGI program (and probably also an
extensive runtime system or interpreter) needs to be loaded and started for each CGI
request.
There is only a single instance which answers all requests concurrently. This saves memory
and allows a Servlet to easily manage persistent data.
Several web.xml conveniences
A handful of removed restrictions
Some edge case clarifications
48. What are the phases of the servlet life cycle?
The life cycle of a servlet consists of the following phases:
Servlet class loading
Servlet instantiation
Initialization (call the init method)
Request handling (call the service method)
Removal from service (call the destroy method)
49. Why do we need a constructor in a servlet if we use the init method?
Even though there is an init method in a servlet which gets called to initialize it, a
constructor is still required to instantiate the servlet. Even though you as the developer would never
need to explicitly call the servlet's constructor, it is still being used by the container (the container
still uses the constructor to create an instance of the servlet). Just like a normal POJO (plain old
java object) that might have an init method, it is no use calling the init method if you haven't
constructed an object to call it on yet.
50. How the servlet is loaded?
A servlet can be loaded when:
First request is made.
Server starts up (auto-load).
There is only a single instance which answers all requests concurrently. This saves memory
and allows a Servlet to easily manage persistent data.
Administrator manually loads.
P.SARANYA,AP/IT 34
51. How a Servlet is unloaded?
A servlet is unloaded when:
Server shuts down.
Administrator manually unloads.
52. What is Servlet interface?
The central abstraction in the Servlet API is the Servlet interface. All servlets implement
this interface, either directly or , more commonly by extending a class that implements it.
53. What is the GenericServlet class?
GenericServlet is an abstract class that implements the Servlet interface and the
ServletConfig interface. In addition to the methods declared in these two interfaces, this class also
provides simple versions of the lifecycle methods init and destroy, and implements the log method
declared in the ServletContext interface.
54. What's the difference between GenericServlet and HttpServlet?
GenericServlet HttpServlet
The GenericServlet is an abstract class that is
extended by HttpServlet to provide HTTP
protocol-specific methods.
An abstract class that simplifies writing HTTP
servlets. It extends the GenericServlet base class
and provides an framework for handling the
HTTP protocol.
The GenericServlet does not include protocol-
specific methods for handling request
parameters, cookies, sessions and setting
response headers.
The HttpServlet subclass passes generic service
method requests to the relevant doGet() or
doPost() method.
GenericServlet is not specific to any protocol. HttpServlet only supports HTTP and HTTPS
P.SARANYA,AP/IT 35
protocol.
55. What is the difference between doGet() and doPost()?
S.No doGet() doPost()
1
In doGet() the parameters are appended to
the URL and sent along with header
information.
In doPost(), on the other hand will (typically)
send the information through a socket back to
the webserver and it won't show up in the
URL bar.
2
The amount of information you can send
back using a GET is restricted as URLs can
only be 1024 characters.
You can send much more information to the
server this way - and it's not restricted to
textual data either. It is possible to send files
and even binary data such as serialized Java
objects!
3
doGet() is a request for information; it does
not (or should not) change anything on the
server. (doGet() should be idempotent)
doPost() provides information (such as
placing an order for merchandise) that the
server is expected to remember
4 Parameters are not encrypted Parameters are encrypted
5
doGet() is faster if we set the response
content length since the same connection is
used. Thus increasing the performance
doPost() is generally used to update or post
some information to the server.doPost is
slower compared to doGet since doPost does
not write the content length
6
doGet() should be idempotent. i.e. doget
should be able to be repeated safely many
times
This method does not need to be idempotent.
Operations requested through POST can have
side effects for which the user can be held
accountable.
7 doGet() should be safe without any side This method does not need to be either safe
P.SARANYA,AP/IT 36
effects for which user is held responsible
8 It allows bookmarks. It disallows bookmarks.
56. When to use doGet() and when doPost()?
Always prefer to use GET (As because GET is faster than POST), except mentioned in the
following reason:
If data is sensitive
Data is greater than 1024 characters
If your application don't need bookmarks.
57. How do I support both GET and POST from the same Servlet?
The easy way is, just support POST, then have your doGet method call your doPost method:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doPost(request, response);
}
58. Should I override the service() method?
We never override the service method, since the HTTP Servlets have already taken care of it
. The default service function invokes the doXXX() method corresponding to the method of the
HTTP request.For example, if the HTTP request method is GET, doGet() method is called by
default. A servlet should override the doXXX() method for the HTTP methods that servlet supports.
Because HTTP service method check the request method and calls the appropriate handler method,
it is not necessary to override the service method itself. Only override the appropriate doXXX()
method.
59. What is session?
A session refers to all the requests that a single client might make to a server in the course of
viewing any pages associated with a given application. Sessions are specific to both the individual
user and the application. As a result, every user of an application has a separate session and has
access to a separate set of session variables.
P.SARANYA,AP/IT 37
60. What is Session Tracking?
Session tracking is a mechanism that servlets use to maintain state about a series of requests
from the same user (that is, requests originating from the same browser) across some period of time.
61. What is the need of Session Tracking in web application?
HTTP is a stateless protocol i.e., every request is treated as new request. For web
applications to be more realistic they have to retain information across multiple requests. Such
information which is part of the application is reffered as "state". To keep track of this state we need
session tracking.
62. What are the types of Session Tracking ?
Sessions need to work with all web browsers and take into account the users security
preferences. Therefore there are a variety of ways to send and receive the identifier:
URL rewriting
Hidden Form Fields
Cookies
Secure Socket Layer (SSL) Sessions
63. How do I use cookies to store session state on the client?
In a servlet, the HttpServletResponse and HttpServletRequest objects passed to method
HttpServlet.service() can be used to create cookies on the client and use cookie information
transmitted during client requests. JSPs can also use cookies, in scriptlet code or, preferably,
from within custom tag code.
To set a cookie on the client, use the addCookie() method in class HttpServletResponse.
Multiple cookies may be set for the same request, and a single cookie name may have
multiple values.
P.SARANYA,AP/IT 38
To get all of the cookies associated with a single HTTP request, use the getCookies()
method of class HttpServletRequest
64. What are some advantages of storing session state in cookies?
Cookies are usually persistent, so for low-security sites, user data that needs to be stored
long-term (such as a user ID, historical information, etc.) can be maintained easily with no
server interaction.
For small- and medium-sized session data, the entire session data (instead of just the session
ID) can be kept in the cookie.
65. What are some disadvantages of storing session state in cookies?
Cookies are controlled by programming a low-level API, which is more difficult to
implement than some other approaches.
All data for a session are kept on the client. Corruption, expiration or purging of cookie files
can all result in incomplete, inconsistent, or missing information.
Cookies may not be available for many reasons: the user may have disabled them, the
browser version may not support them, the browser may be behind a firewall that filters
cookies, and so on. Servlets and JSP pages that rely exclusively on cookies for client-side
session state will not operate properly for all clients. Using cookies, and then switching to
an alternate client-side session state strategy in cases where cookies aren't available,
complicates development and maintenance.
Browser instances share cookies, so users cannot have multiple simultaneous sessions.
Cookie-based solutions work only for HTTP clients. This is because cookies are a feature of
the HTTP protocol. Notice that the while package javax.servlet.http supports session
management (via class HttpSession), package javax.servlet has no such support.
66. What is URL rewriting?
URL rewriting is a method of session tracking in which some extra data is appended at the
end of each URL. This extra data identifies the session. The server can associate this session
identifier with the data it has stored about that session.
Every URL on the page must be encoded using method HttpServletResponse.encodeURL().
Each time a URL is output, the servlet passes the URL to encodeURL(), which encodes session ID
in the URL if the browser isn't accepting cookies, or if the session tracking is turned off. E.g.,
http://abc/path/index.jsp;jsessionid=123465hfhs
P.SARANYA,AP/IT 39
67. How can the session in Servlet can be destroyed?
An existing session can be destroyed in the following two ways:
Using session.invalidate() method, which makes the container abonden the session on which
the method is called.
When the server itself is shutdown.
68. What is servlet lazy loading?
A container doesnot initialize the servlets ass soon as it starts up, it initializes a servlet when
it receives a request for that servlet first time. This is called lazy loading.
The servlet specification defines the <load-on-startup> element, which can be specified in the
deployment descriptor to make the servlet container load and initialize the servlet as soon as it starts
up.
The process of loading a servlet before any request comes in is called preloading or
preinitializing a servlet.
69. What is Servlet Chaining?
Servlet Chaining is a method where the output of one servlet is piped into a second servlet.
The output of the second servlet could be piped into a third servlet, and so on. The last servlet in the
chain returns the output to the Web browser.
70. What are the functions of the Servlet container?
The functions of the Servlet container are as follows:
Lifecycle management
Communication support
Multithreading support
Declarative security
JSP support
P.SARANYA,AP/IT 40
PART B
1. Discuss the components of JSP
JSP component architecture
Directive elements
Page Directive
Include Directive
Tag Library directive
Scripting element
Declaration
Expression
Scriplet
Action elements
Standard Action(Forward,Include,Use Bean)
Custom Action
2. Explain implicit objects with example.
Define the nine implicit objects
Object Class
application javax.servlet.ServletContext
config javax.servlet.ServletConfig
exception java.lang.Throwable
out javax.servlet.jsp.JspWriter
page java.lang.Object
PageContext javax.servlet.jsp.PageContext
request javax.servlet.ServletRequest
response javax.servlet.ServletResponse
session javax.servlet.http.HttpSession
Explain any three with an example
3. Explain in details about taglib.
Definition
Syntax:
P.SARANYA,AP/IT 41
"<%@ taglib uri= "URIToTagLibrary" prefix="tagPrefix" %>"
Need for taglib
Example
4. Explain the architechture of a Servlet?
Servlet architecture made by two packages :
javax.servlet.Servlet
javax.servlet.http
It consist of one basic interface and 2 abstract classes, they are :
Servlet Interface
GenericServlet Abstarct Class
HttpServlet Abstarct Class
The Servlet interface defines 5 methods. The main 3 most important are :
init() - Initializes a servlet
service() - Receives and responds to Client requests
destroy() - Perform cleanup operation
The two methods throws Exceptions :
void init( ServletConfig config ) throws ServletException
void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException
Servlet Architecture diagram
5. Explain session tracking in Java Servlet.
Definition for session tracking
Explain the 5 different mechanisms for session tracking:
User Authorization
Hidden fields
URL rewriting
Cookies
Session tracking API.
6. Write a HTTP servlet program to authenticate a user and retrieve all information from a
HTML registration Form and store in a given data base.
Develop a registration form using HTML
P.SARANYA,AP/IT 42
Use a Servlet to store the details in the database
Create a login page using HTML
Validate the details in the login page using the servlet.
7. Write a short notes on Some of the JSP related technologies
JSP scriplets
ASP.net vs. ASP
PHP
Cold fusion
8. Explain the concept of Servlets with an example program
Servlet definition
Advantage of servlet
Use simple program to explain servlet
P.SARANYA,AP/IT 43
UNIT IV
ASP
PART A
1. What is ASP?
ASP stands for Active Server Pages.
It is a server side technology which is used to display dynamic content on web pages. For
example you could write code that would give your visitors different information, different images
or even a totally different page depending on what browser version they are using.
2. How can you disable the browser to view the code?
Writing codes within the Tag
3. What is a “Virtual Directory”?
Virtual directories are aliases for directory paths on the server. It allows moving files on the disk
between different folders, drives or even servers without changing the structure of web pages. It
avoids typing an extremely long URL each time to access an ASP page.
4. Give the comment Tags for the following?
VBScript : REM & ‗(apostrophe)
JavaScript : // (single line comment)
/* */ (Multi-line comments)
5. Which is the default Scripting Language of ASP (server-side)?
VBScript
6. Which is the default Data types in VBScript?
Variant is the default data type in VBScript, which can store a value of any
type.
7. What is a variable?
Variable is a memory location through which the actual values are stored/retrieved. Its value
can be changed.
8. What is the maximum size of an array?
Up to 60 dimensions.
9. What is Query string collection?
This collection stores any values that are provided in the URL. This can be generated by
three methods:
P.SARANYA,AP/IT 44
By clicking on an anchor tag
By sending a form to the server by the GET method
Through user-typed HTTP address
It allows you to extract data sent to the server using a GET request.
10. What are the attributes of the tags? What are their functions?
The two attributes are ACTION and METHOD
The ACTION gives the name of the ASP file that should be opened next by which
this file can access the information given in the form.
The METHOD determines which of the two ways (POST or GET) the browser can send the
information to the server
11. What are the methods in Session Object?
The Session Object has only one method, which is Abandon. It destroys all the objects
stored in a Session Object and releases the server resources they occupied.
12. What is ServerVariables collection?
The ServerVariables collection holds the entire HTTP headers and also additional
items of information about the server.
13. What is the difference between Querystring collection and Form collection?
The main difference is that the Querystring collection gets appended to a URL.
14. What is a Form collection?
The Form collection holds the values of the form elements submitted with the
POST method. This is the only way to generate a Form collection.
15. What are the ASP Scripting Objects?
The Dictionary object, the FileSystemObject object, TextStream object.
16. What happens to a HTML page?
The browser makes a HTTP request; the server gives a HTTP response to the
browser and the browser converts into a HTML page.
17. What happens to ASP pages?
The browser makes a HTTP request; the server does the processing and gives a
HTML response to the browser.
18. How can you change the primary scripting language for a page?
Specify
P.SARANYA,AP/IT 45
19. What is application Object?
Shares information among users of an application. Gives a notification when an application
starts or ends.
20. What is the difference between client-side script and server-side script?
A script executed only by the browser without contacting the server is called client-side
script. It is browser dependent. The scripting code is visible to the user and hence not secure. A
script executed by the web server and processed by the server is called server-side script.
21. What is the command to display characters to the HTML page?
Response.Write()
22. Explain the POST & GET Method or Explain the difference between them?
POST METHOD: The POST method generates a FORM collection, which is sent as a
HTTP request body. All the values typed in the form will be stored in the FORM collection.
GET METHOD: The GET method sends information by appending it to the URL (with a
question mark) and stored as A Querystring collection. The Querystring collection is passed
to the server as name/value pair. The length of the URL should be less than 255 characters.
23. How many global.asa files can an Application have?
Only one global.asa file and it‘s placed in the virtual directory‘s root.
24. How many global.asa files can an Application have?
Only one global.asa file and it‘s placed in the virtual directory‘s root.
25. What are Scripting Objects?
Objects that can enhance the application are known as the Scripting Objects.
26. What is the Order of precedence for LOGICAL Operators ?
NOT, AND, OR, XOR, EQV, IMP
27. What is an Err Object?
Name it‘s properties and methods.
28. What are LOCAL and GLOBAL variables?
Local variables lifetime ends when the Procedure ends. Global variables lifetime begins at
the start of the script and ends at the end of the script and it can be used by any procedure within the
script. Declaring a variable by using the keyword PRIVATE makes the variable global within the
script, but if declared using PUBLIC, then all scripts can refer the variable.
29. Which is the default Scripting Language on the client side?
P.SARANYA,AP/IT 46
JavaScript
30. What is HTML (Hypertext Markup Language)?
It‘s a method by which web pages can be built and generally used for formatting
and linking text.
31. What is a Web Server?
It‘s a Computer that provides Web services on the Internet or on a local Intranet. It is
designed to locate, address and send out simple HTML pages to all other users who access these
pages.
32. What is Session Object?
It stores information about a User‘s session. Gives a notification when a user session begins
or ends.
33. What is Server-Side includes?
It provides extra information by which it makes the site easier to manage. It can include text
files using the #include statement, retrieve the size and last modification date of a file, defines how
variables and error messages are displayed and inserts the values of HTTP variables in the page sent
back to the browser.
34. What is a FileSystemObject object?
It provides access to the physical file system of the web server. It gets and manipulates
information about all drives in a server, folders and sub-folders on a drive and files inside a folder.
35. What is a Scripting Language?
It permits to create more interactive Web Pages. Validation, formatting of web pages can be
done. VBScript, JavaScript are some examples.
36. What is a Dictionary object?
It lets you store and retrieve information in a flexible data structure. Each value or
information stored in a Dictionary is associated with a key through which the information can be
retrieved.
37. What is Global.asa file?
It is text file that contains details about an ASP application, such as when it should begin
and end.
38. What is an .ASP file?
It is a Text File that contains the combination of the following:
P.SARANYA,AP/IT 47
Text
HTML tags
Script Commands
39. What is Response Object?
It controls the information sent to the user. The various methods are:
Response.Write – Sends information directly to a browser
Response.Redirect – Directs a user to a URL other than the requested URL
Response.ContentType – Controls the type of content sent
Response.Cookies – Sets cookie values
Response.Buffer – To Buffer information
40. Naming constraints for a variable ?
It can be up to 255 characters Must start with an alphabet Must not contain an embedded
period or full-stop
41. What is a TextStream object?
It allows you to access(read/write) the contents of text files stored on the web server.
42. What is IIS?
IIS is a Web Server that provides Web services, not only for web pages but also for ftp sites
and video and audio services. It integrates with the database facilities of SQL Server.
43. What is Request Object?
Gets information from the user. It has five collections by which values can be accessed.
They are: Query string, Form, Cookies, Server Variables & Client Certificate
44. What are the special sub-types in VBScript?
EMPTY: has no value
NULL: Value does not exist (conjunction with database)
OBJECT:
45. What is Cookies collection?
Cookies are text files that store information about the user by which the web server
identifies and marks each different visitor to a web site and determines where a user has been
before. A cookie can store information only when the user sends it. Individual cookies are limited to
4KB of data. The maximum number of cookies allowed is 300. Cookies are stored on client‘s
machine.
P.SARANYA,AP/IT 48
46. What is the difference between Cookies collection and Form/Query string collection?
Cookie collection does not have the Count property. Cookies can have multiple values for
the same cookie name but each value can be referred using a key whereas in a Form/Query string
cookie each value has to be referred using an index value.
47. What is Server Object?
Controls the ASP execution environment. It can set the amount of time script can run before
an error occurs. Converts a virtual path to a physical path on the server. Takes a user supplied string
and encode it into proper format for a URL string.
48. What is Collection?
Collection is a set of name/value pairs where the information supplied by the client is stored.
49.How will you delete a Cookie?
By setting its Expires property to any date prior to today Response.Cookies(―cookie name‖).
Expires = Date 1.
50. What is the function of Buffer in Response Object?
Buffer controls the HTML output stream manually.
51. How are scripts executed?
ASP provides scripting engines that execute the corresponding scripting languages on the
server side. Scripts should be encoded within the Delimiters.
52. What is ASP (Active Server Pages)?
ASP is a server side-scripting environment for building dynamic and interactive web pages.
Since the scripts run on the server side, the web server does all the processing.
53. What are arrays?
Arrays are variables that store items of similar information.DIM ARRAY1(4) (declares an
array with the name array1 with 5 elements)
54. What is Application-scope?
Application-scope means that variables (and objects) can be accessed from any ASP pages
that is part of the application.
55. What are the types of HTML?
Static HTML Browser uses HTTP to request HTML file from the Web Server
Dynamic HTML Browser uses HTTP to request an executable application rather than a
Static HTML file
P.SARANYA,AP/IT 49
56. What are the properties of Session Object?
SessionID returns the session identification number for each user.
Timeout sets the timeout period assigned to the Session object for any application, in
minutes.
CodePage determines the code page that will be used to display content.
LCID a locale identifier, which determines time zone and language, rules for the system
57. What are the event handlers of Session Object?
Session _OnStart This event will be fired when a new user begins a session with the web
site.
Session_OnEnd This event is called whenever a session terminates.
58. Name the ASP Objects?
Request Object
Response Object
Server Object
Session Object
Application Object
59. What are the advantages of using ASP?
Minimizes network traffic by limiting the need for the browser and server to talk to each
other Makes for quicker loading time since HTML pages are only downloaded Allows to run
programs in languages that are not supported by the browser Can provide the client with data that
does not reside on the client‘s machine Provides improved security measures since the script cannot
be viewed by the browser
60. What are the methods in Application Object?
Lock prevents clients from modifying the variables stored in the Application
object.
Unlock removes the lock from variables stored in the Application object.
61. What are the servers in Application Object?
Internet Information Server (IIS) on Windows NT
Personal Web Server (PWS) on Windows 95
Peer Web Services on Windows NT
62. What are the browsers that can access ASP pages?
P.SARANYA,AP/IT 50
Internet Explorer (supports VBScript, JavaScript)
Netscape Communicator/ Navigator (supports only JavaScript, VBScript can be also added
too)
63. How does the server identify and execute the server-side scripts within HTML code?
Including the RUNAT=SERVER attribute
64. What are the methods by which output stream is controlled?
Flush sends previous buffered output to the client immediately, but continues processing the
script. Clear erases any already-buffered HTML. End causes the server to stop processing the script.
65. What are the properties used to control the expiration of the page?
Expires specifies the number of minutes before a page cached on a browser expires.
ExpiresAbsolute sets the date and time at which a page cached on a browser expires.
66. What are the collections of Session Object?
Contents collection contains all the variables established for a session without using the tag.
Static collection contains all the objects created
67. What is the difference between ASP and HTML? Or Why ASP is better than HTML?
ASP executes code on the server side whereas the browser interprets HTML.
ASP can use any scripting languages
Gets feedback from the user and return information to the user
Create pages that will be customized to display only things that will be of interest to a
particular user
Can edit contents of a web page by updating a text file or a database rather than the HTML
code itself
68. What are the event handlers of Application Object?
Application_OnStart- This event will be fired when the first visitor hits the page.
Application_OnEnd- This event runs when the server is stopped.
69. Name some of the ASP components?
Ad Rotator component- a way to manage advertisements on the web site.
Content Linker component – a technique to direct users through a set of pages on a web site
by creating a list of URLs and description of the next and previous pages.
Browser Capabilities component – allows to customize the page to the ability of the browser
viewing it.
P.SARANYA,AP/IT 51
Database Access component – allows to access data from the database
70. What are the tasks performed by < FORM > tags?
tags provides space for the user to input values the form has a button to submit information
back to the server It transfers control to another ASP page It carries the information in the fields to
another ASP page
71. What are the tags necessary to be present within the <FORM > tag?
Provides input spaces (text boxes, combo boxes, radio button, etc.) on a form called fields. It
has three attributes TYPE, NAME and VALUE. TYPE provides the characteristics of the field and
the NAME specifies a name to the field by which it can be referred.
72. What are the collections of Application Object?
Contents collection – contains all variables added via scripts in global.asa.
Static collection – contains the names of all objects.
73. Explain the difference between POST and GET Method.
GET requests are string data that is visible to the end user via the URL and a limit of 2kb,
POST requests have no limit on total data and the user can‘t see the data in a query string.
74. Why do we use Option Explicit?
To avoid multiple variables of the same name.
This statement forces the declaration of variables in VB before using them.
75. How do you write an SQL insert statement?
insert into tablename (fieldA, fieldB, fieldC)Values(‘dataA‘, ‗dataB‘, ‗dataC‘);
76. How can you have different number of cells for each row of a table in HTML?
using colspan and rowspan
77. What variable can you use to share info across the whole application for one user?
Use the sessions object
78. What is string concatenation function in VBScript?
The ampersand symbol and ampersand space underscore across multiple lines
79. Which is the default Data types in VBScript?
Variant.
PART B
1. Explain about ASP Objects with suitable example?
ASP Object
P.SARANYA,AP/IT 52
ASP Object Overview
ASP Create an Object - Server.CreateObject
ASP Object Properties
ASP Object Methods
Example
2. Write short note on Cookies with example
Definition
Advantages of cookies
Disadvantage of cookies
Creating a cookie
Retrieving a cookie
Example
3. What is the difference between ASP and HTML? Or Why ASP is better than HTML?
Explanation
Advantage
Disadvantage
4. How many global.asa files can an Application have?
The Global.asa file
Application events
Session events
<object> declarations
TypeLibrary declarations
the #include directive
Events in Global.asa
Application_OnStart
Session_OnStart
Session_OnEnd
Application_OnEnd
<object> Declarations
TypeLibrary Declarations
Global.asa Example
P.SARANYA,AP/IT 53
5. Write short notes on ASP session object.
Explanation
Storing & retrieving of session variable
Removing session variable
Example
6. Write short notes on ASP request & response object.
Explanation
Elements
Methods
Example
P.SARANYA,AP/IT 54
UNIT V
C# AND .NET FRAMEWORK
PART A
1. What Is the .NET Framework?
The .NET Framework is an environment that supports the development and execution of highly
distributed, component-based applications. It enables differing computer languages to work
together and provides for security, program portability, and a common programming model for the
Windows platform.
2. What are the components of .net framework?
There are two major components which makes the .net framework are CLR and class library.
CLR: The first is the Common Language Runtime (CLR), which is the runtime environment of all
programming languages in the framework and manages the execution of your program. Class
Library: The second entity is the .NET class library. This library gives your program access to the
runtime environment.
3. What is use of CLS?
The CLS defines the necessary things as common variable types (this is called the Common
Type System CTS ), common visibility like when and where can one see these variables, common
method specifications, and so on.
4. Define the Common Language Runtime (CLR)
The heart of .net Framework is Common Language Runtime (CLR). All .NET-compliant
languages run in a common, managed runtime execution environment. With the CLR, you can rely
on code that is accessed from different languages.
5. What is JIT and how is works?
The CLR includes something called a JIT compiler in which the compiler order is as follows.
Source Code => Compiler => Assembly =>Class Loader =>Jit Compiler =>Manged Native
Code=>Execution.
6. Define MSIL
Microsoft Intermediate Language (MSIL) is a platform independent language that gets compiled
into platform dependent executable file or dynamic link library. It means .NET compiler can
generate code written using any supported languages and finally convert it to the required machine
code depending on the target machine.
P.SARANYA,AP/IT 55
7. What is the advandage of using MSIL
The main advantages of IL are:
1. IL isn‘t dependent on any language and there is a possibility to create applications with modules
that were written using different .NET compatible languages.
2. Platform independence - IL can be compiled to different platforms or operating systems.
8. Define Common Language Infrastructure
The Common Language Infrastructure (CLI) is a specification that allows several different
programming languages to be used together on a given platform.
9. What are the parts of CLI?
Parts of the Common Language Infrastructure:
Common Intermediate language (CIL) including a common type system (CTS)
Common Language Specification (CLS) - shared by all languages
Virtual Execution System (VES)
Metadata about types, dependent libraries, attributes, and more
10. How does C# differ from C++?
C# compiles straight from source code to executable code, with no object files.
C# does not separate class definition from implementation. Classes are defined and
implemented in the same place and therefore there is no need for header files.
In C#, class definition does not use a semicolon at the end.
C# does not support #include statement.
11. How does C# differ from Java?
Although C# uses .NET runtime that is similar to Java runtime, the C# compiler produces an
executable code
C# has more primitive .data type~.
Unlike Java, all C# data types are objects. 04. Arrays are declared differently in C#.
Although C# classes are quite similar to Java classes, there are a few important differences
relating to constants, base classes and Constructors, versioning, accessibility of members
etc.
C# supports the struct type and Java does not. 07. Java does not provide operator
overloading.
P.SARANYA,AP/IT 56
12. Define C# Value Types and Reference Types
C# permits the use of value types, such as enumerations and structures, and reference types,
such as objects instantiated from classes. Value types hold their data directly and can be easily
copied. Reference types add a layer of indirection.
13. What are C# Operators?
14. What are the String Operators?
Concatenation Operator
Relational Operators
Null Coalescing Operator
15. Define C# branching statements
P.SARANYA,AP/IT 57
16. What are the parameter types employed in C#?
C# employs four kinds of parameters.
1. value parameter
2. Reference parameter
3. Output parameter
4. Parameter array
17. What is a struct in C#?
A struct is a value type. While a struct is a value type, a class is a reference type. Value types hold
their value in memory where they are declared, but reference types hold a reference to an object in
memory.
18. Define jagged array
A jagged array is actually a nested array of arrays, declared using two pairs of square brackets
rather than a single pair with two dimension sizes. Only the number of rows is specified in the
initial declaration; the individual rows are sized or initialized individually.
19. Define foreach loop.
A foreach loop is used to iterate through the items in a list. It operates on arrays or collections such
as ArrayList, which can be found in the System.Collections namespace. The syntax of a foreach
loop is
foreach (<type> <iteration variable> in <list>) { <statements> }
The type is the type of item contained in the list. For example, if the type of the list was int[] then
the type would be int. The iteration variable is an identifier that you choose, which could be
anything but should be meaningful. For example, if the list contained an array of people's ages, then
a meaningful name for item name would be age. The in keyword is required. While iterating
P.SARANYA,AP/IT 58
through the items of a list with a foreach loop, the list is read-only. This means that you can't
modify the iteration variable within a foreach loop.
20. What are the ways to reuse C# classes?
The mechanism of designing or constructing one class from another is called inheritance.
This may be achieved in two different forms.
1. Classical form
2. Containment form
21. Define Containment Inheritance
Another form of inheritance relationship known as containership between class A and B
Example:
class A
{
---------
}
class B
{
---------
A a; // a is contained in b
}
B b;
---------
22. What is overriding methods?
A method defined in a super class is inherited by its subclass and is used by the objects created by
the subclass. Method inheritance enables us to define and use methods repeatedly in sub classes.
1. We specify the method in base class as virtual
2. Implement the method in subclass using the keyword override
This is known as overriding.
23. Define polymorphism
Polymorphism mean „one name, many forms‟, essentially, polymorphism is the capability of one
object to behave in multiple ways.
P.SARANYA,AP/IT 59
24. Define Operator Overloading.
Operator overloading is closely related to method overloading. To overload an operator, you use the
operator keyword to define an operator method, which defines the action of the operator relative to
its class. There are two forms of operator methods: one for unary operators and one for binary
operators.
25. Define delegate
A delegate object is a special type of object that contains the details of a method rather than data.
Delegates in C# are used for two purposes:
1. Callback
2. Event Handling
P.SARANYA,AP/IT 60
PART B
Explain the brief history of C#
Explain the Language Hierarchy
ANSI C++
Martin
Richards
1967
1972
Ken Thompson
1970
1983
1987
1996
1995
1991
2000
Dennis Ritchie
ANSI Committee
Bjarne Stroustrup
James Gosling
Sun Microsystems
ANSI Committee
Microsoft
Java
Oak
C++
BCPL B
C
ANSI C
C#
P.SARANYA,AP/IT 61
Explain the Evolution of C#
Explain the characteristics of C#
Simple
Consistent
Modern
Object – Oriented
Type – Safe
Versionable
Compatible
Interoperable
Flexible
Explain how C# differs from C++ and Java.
C# vs C++
Definition
Advantages
Disadvantages
C# vs Java
C++
Java C#
VB
Concept Concept
C
Object
Ori.
Component
Orientation Elegance
ientation
Power
Elegance Productivity
P.SARANYA,AP/IT 62
Definition
Advantages
Disadvantages
Explain in detail about the .NET framework.
Explanation
.NET architecture
Technology components:
Development tools.
Specialized servers.
Web services.
Devices.
The .Net platform consists of five main components:
Operating system layer.
.NET building block services.
.NET framework.
.NET servers
Visual Studio .NET.
Common Language Runtime(CLR)
5. Write short notes on CLS,CLR,MSIL
.Net Common Language Specifications (CLS)
Explanation
Usage
The Common Language Runtime (CLR)
Explanation
Usage
Microsoft Intermediate Language (MSIL)
Explanation
Usage
6. Explain in detail about C# control structures.
Control structures in C#
If Statement
P.SARANYA,AP/IT 63
Explanation
Syntax
Example
Switch
Explanation
Syntax
Example
Continue
Explanation
Syntax
Example
Goto
return
throw
***** All The Best *****
P.SARANYA,AP/IT 64
ANNA UNIVERSITY OF TECHNOLOGY, COIMBATORE
B.E/B.TECT. DEGREE EXAMINATION: NOV/DEC 2010
REGULATIONS: 2008
SEVENTH SEMESTER: INFORMATION TECHNOLOGY
080250042 - WEB TECHNOLOGY
Time: 3 Hours Max. Marks: 100
PART – A (10 x 2 = 20 MARKS)
ANSWER ALL QUESTIONS
1. What is SOA? List out the features of service model in SOA.
2. What are the layers of standards in technology stack cl the SOA?
3. Define three tiers architecture. Name the three tiers.
4. Write the xsn syntax for copying nodes?
5. Name the different types or XML tools
6. List out the different border styles in cascading style sheet.
7. Write a XML program to store employee details with root element as EMPLOYEE and sub
elements are EMP_ID, EMP_NAME, EMP_DEFT, ROLE & MANAGER.
8. Differentiate between XML and HTML.
9 What are the characteristics of servlets?
I0. Draw the life cycle of servlet.
11. Define cookies. What are the characteristics of cookies‘?
12. Differentiate between CGI and Servlets.
13. What are the component services in J2EE?
14. Write the tags for <FRAMESET>.Give one example.
15. Write the syntax for embedding VB Script into HTML with an example?
16. What are the scoping issues in ASP applications?
17. What are the Asp objects?
18. Define CTS.
19 What are the components present in .NET platform?
20. Write a sample program in C#
ANSWER ANY 5 QUESTIONS
21. Explain in detail about the service roles.
P.SARANYA,AP/IT 65
22. Explain in detail about Electronic Data Interchange.
23. a) Explain about well-formed XML Document. (8)
b) Write short notes on entities & elements. (4)
24. Explain in detail about session tracking.
25. Write HTML and VB script program to develop a Hostel Management website using frame,
table and form tag.
26. Explain about any three ASP objects in details.
27. a) Explain in detail about .NET framework. (8)
b) Explain in detail about CLR. (4)
28. Define JSP. Explain in detail about JSP components.
P.SARANYA,AP/IT 66
PART- A
1) SOA is an architectural style for building software applications that use services available in a
network such as the web. It promotes loose coupling between software components so that they can
be reused.
2)
3) A special type of client/server architecture consisting of three well-defined and separate
processes, each running on a different platform:
1. The user interface, which runs on the user's computer (the client).
2. The functional modules that actually process data. This middle tier runs on a server and is often
called the application server.
3.A database management system (DBMS) that stores the data required by the middle tier. This tier
runs on a second server called the database server
The 3-Tier architecture has the following three tiers.
Presentation Tier
Logic Tier / Business Logic Tier / Transaction Tier
Data Tier
4) XSLT - it is an XML- based languages used to transform XML documents into others format
such as HTML for web display.
5)XML tools
XPath
XQuery
XLink
6) The standard border is written in CSS as:
border-style: solid;
P.SARANYA,AP/IT 67
border-width: 1px;
border-color: black;
7)XML program
<?xml version=‖1.0‖?>
<EMPLOYEE>
<EMP_ID>E1001</EMP_ID>
<EMP_NAME>JOHN</EMP_NAME>
<EMP_DEPT>INFORMATION TECHNOLOGY</EMP_DEPT>
<ROLE>PROGRAMMER</ROLE>
<MANAGER>EDWARD</MANAGER>
</EMPLOYEE>
8)HTML vs XML
HTML XML
HTML is for displaying purpose. whereas XML is for data representation.
HTML is used to mark up text so it can be
displayed to users.
XML is used to mark up data so it can be
processed by computers.
HTML describes both structure (e.g. <p>, <h2>,
<em>) and appearance (e.g. <br>, <font>, <i>) XML describes only content, or ―meaning‖
HTML uses a fixed, unchangeable set of tags In XML, you make up your own tags
9)Servlet characteristics
1. Servlets are efficient.
2. Servlets are robust.
3. Servlets are portable.
4. Servlets are persistent.
10) Life cycle of Servlet
The life cycle of a servlet can be categorized into four parts:
1. Loading and Instantiation
2. Initialization
P.SARANYA,AP/IT 68
3. Servicing the Request
4. Destroying the Servlet
11) Cookie is a small amount of information sent by a servlet to a Web browser. Saved by the
browser, and later sent back to the server in subsequent requests. A cookie has a name, a single
value, and optional attributes. A cookie's value can uniquely identify a client.
12) CGI (Common gateway interface) & Servlet
1. CGI is platform dependent Servlet is platform independent.
2. CGI creates a new process for each request. Servlet creates a thread for each request and service
the request in that thread.
3. CGI is not based on pooling (which hold no external resource but occupy memory i.e. not
destroy after used) Its container managed pooling object.
4. CGI has no session tracking mechanism. It supports session tracking mechanism
for each process created by CGI the process assign the separate address. so there is memory
overload on the server For each thread created by Servlet no separate address space is created.
5. All thread operates in the same parent address space (it is created when Servlet is load at first
time). so there is no memory overload on the server CGI Build with scripting languages (like C,
C++, Perl etc) Servlet build with java.
13) J2EE (Java 2 Enterprise Edition) is an environment for developing and deploying enterprise
applications. The J2EE platform consists of J2EE components, services, Application Programming
Interfaces (APIs) and protocols that provide the functionality for developing multi-tiered and
distributed Web based applications.
A J2EE component is a self-contained functional software unit that is assembled into a J2EE
application with its related classes and files and communicates with other components.
14) The <frameset> tag defines a frameset.
P.SARANYA,AP/IT 69
The <frameset> element holds one or more <frame> elements. Each <frame> element can hold a
separate document.
The <frameset> element specifies HOW MANY columns or rows there will be in the frameset, and
HOW MUCH percentage/pixels of space will occupy each of them.
<frameset cols="25%,*,25%">
<frame src="frame_a.htm" />
<frame src="frame_b.htm" />
<frame src="frame_c.htm" />
</frameset>
15)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>A document with SCRIPT</TITLE>
<META http-equiv="Content-Script-Type" content="text/tcl">
<SCRIPT type="text/vbscript" src="http://someplace.com/progs/vbcalc">
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT type="text/vbscript">
...some JavaScript...
</SCRIPT>
</BODY>
</HTML>
16) ASP is a server side-scripting environment for building dynamic and interactive web pages.
Since the scripts run on the server side, the web server does all the processing
17) ASP Objects
Request Object
P.SARANYA,AP/IT 70
Response Object
Server Object
Session Object
Application Object
18) The CLS defines the necessary things as common variable types (this is called the Common
Type System CTS )
19) There are two major components which makes the .net framework are CLR and class library.
CLR: The first is the Common Language Runtime (CLR), which is the runtime environment of all
programming languages in the framework and manages the execution of your program. Class
Library: The second entity is the .NET class library. This library gives your program access to the
runtime environment.
20) using System;
class ExampleClass
{
static void Main()
{
Console.WriteLine("Hello, world!");
}
}
PART-B
21) There are three major roles within the web service architecture:
Service provider
Service requestor
Service registry
SOA
Architectural process
22) EDI
EDI Standards
EDI Processes
Outbound Process
Inbound Process
P.SARANYA,AP/IT 71
The EDI file structure
EDIFACT
EDI message
EDI Mapping
EDI Message structure
EDI Electronic Enveloping
23 a) Well-formed XML
Explain the well-formed XML document
Define the syntax rules
Example
b) XML
1) Entities
Definition
Types of Entities
Predefined Entities
Parameter Entities
Example
2) Elements
Definition
Elements used in three ways:
Simple Content
Element as container for other Elements
Empty Element as container for Attributes
Element Naming Rule
24) Session Tracking:
Need of Session Tracking
Types of Session Tracking
URL rewriting
Hidden Form Fields
Cookies
Secure Socket Layer (SSL) Sessions
P.SARANYA,AP/IT 72
Example
25) Program
Design the web page using HTML tags
Embed the VBScript to check the availability
Allow the Booking process.
26) ASP Objects
Request Object
Response Object
Server Object
Session Object
Application Object
Definition
Properties
Methods
Severs
Event handlers
Collections
27) .NET is a Microsoft framework.
Explanation
.NET architecture
Technology components:
Development tools.
Specialized servers.
Web services.
Devices.
The .Net platform consists of five main components:
Operating system layer.
.NET building block services.
.NET framework.
.NET servers
Visual Studio .NET.
P.SARANYA,AP/IT 73
Common Language Runtime(CLR)
28) JSP
JSP component architecture
Directive elements
Page Directive
Include Directive
Tag Library directive
Scripting element
Declaration
Expression
Scriplet
Action elements
Standard Action(Forward,Include,Use Bean)
Custom Action
P.SARANYA,AP/IT 74
ANNA UNIVERSITY OF TECHNOLOGY, COIMBATORE
B.E/B.TECT. DEGREE EXAMINATION: NOV/DEC 2011
REGULATIONS : 2008
SEVENTH SEMESTER : INFORMATION TECHNOLOGY
080250042 - WEB TECHNOLOGY
Time: 3 Hours Max.Marks: 100
PART – A (10 x 2 = 20 MARKS)
Answer All Questions:
1. State the goals to design the web service.
2. Define WSDL.
3. What is XML Parser?
4. Write short note on XML namespace.
5. Define JAX-RPC.
6. Differentiate Client-side scripting and Server-side scripting.
7. What are the different types of J2EE Container? Briefly explain their purpose.
8. Develop a VBScript program to perform arithmetic operations.
9. What are the characteristics of C#?
10.List out the services provided by CLR.
PART-B (5*16=80 marks)
Answer any 5 Questions
11. (a) i) Explain three tier Web-based Architecture with diagram. (10)
ii) Briefly explain the benefits of Web Services. (6)
(or)
(b) i) Explain in detail about SOA. (10)
ii) Elucidate the Architecture of Web Service with suitable diagram. (6)
12. (a) i)Create an XML document for Library Management System and apply styles using
CSS(10)
ii)Write short note on Components of XML document. (6)
(or)
b) Explain in detail about different types of Style Sheets used with XML document and give an
P.SARANYA,AP/IT 75
example for every type. (16)
13. (a) i)Explain in detail about Servlet Life Cycle. (10)
ii)Develop a servlet program to explain the client-server communication by writing "Hello
World" servlet. (6)
(or)
b) i) What are the Components of JSP? Explain it in detail. (10)
ii) Develop an application to perform result analysis for an Education Institution using JSP.(6)
14. (a) Explain about ASP Objects with suitable example. (16)
(or)
b) i)Create a web page for on-line Money Transfer using HTML and VBScript. (10)
ii) Write short note on Cookies with example. (6)
15. a)Explain in detail about .NET framework Architecture and Components with suitable
diagram (16)
(or)
b) i) Create an application for Payroll processing using C#.Net. (10)
ii) Write a C# program to sort an array of integers. (6)
P.SARANYA,AP/IT 76
PART – A
1. Web Services
It is both a process and set of protocols for finding and connecting to Software exposed as
services over the Web.
Web Services builds on a SOAP foundation & facilitates software interaction.
2. WSDL – Web services Description language.
An XML description of both the service interface & the implementation details of how to
connect to and use a particular Web Service.
3. An XML parser is a piece of software which can do following:
Check for well-formedness
Validate the document
Allows us to read, create or modify existing XML documents
4. Namespaces
Namespaces eliminates the ambiguity of the same name from different providers.
Namespaces use URLs to distinguish names.
The XML namespaces recommendation allows identical element names from different
sources to be distinguished.
Namespace Declarations
5. JAX-RPC stands for Java API for XML-based RPC. It's an API for building Web services and
clients that used remote procedure calls (RPC) and XML. Often used in a distributed
client/server model, an RPC mechanism enables clients to execute procedures on other systems.
6. Server-side scripting is a web server technology in which a user's request is fulfilled by running
a script directly on the web server to generate dynamic HTML pages. It is usually used to
provide interactive web sites that interface to databases or other data stores. 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.
7. J2EE server
The runtime portion of a J2EE product. A J2EE server provides EJB and Web containers.
Enterprise JavaBeans (EJB) container
Web container
P.SARANYA,AP/IT 77
Application client container
Applet container
9. Characteristics of C#
Consistent
Modern
Object Oriented
Type Safe
Versionable
Flexible
10. The heart of .net Framework is Common Language Runtime (CLR). All .NET-compliant
languages run in a common, managed runtime execution environment. With the CLR, you
can rely on code that is accessed from different languages.
PART – B
11) a)i)
The 3-Tier architecture has the following three tiers.
Presentation Tier
Logic Tier / Business Logic Tier / Transaction Tier
Data Tier
Diagram
Example
Web development usage
ii)
1. Decide on the service it wants to provide
2. Pick a registry for uploading it‘s information
3. Decide how to list its service at the registry
4. Define explicitly how users can connect to its service
b) i)
Definition
Characteristics of SOA
Diagram
Service Oriented roles
P.SARANYA,AP/IT 78
Service provider
Service broker
Service requester
SOA protocols
UDDI
WSDL
SOAP
LDAP
ii)
Web Services Paradigm
Web Services – Protocols(explanation)
Web Services Protocol Stack(Diagram)
Web Services Process Architecture(explanation)
Web Services Process Architecture(Diagram)
12. a) Components of XML document
Processing Instructions
Tags
Elements
Content
Attributes
Entities
Comments
b) There are three types of CSS styles:
inline styles
embedded styles
external styles
13. a)Servlet Life Cycle
P.SARANYA,AP/IT 79
13 b) JSP
JSP component architecture
Directive elements
Page Directive
Include Directive
Tag Library directive
Scripting element
Declaration
Expression
Scriplet
Action elements
Standard Action(Forward,Include,Use Bean)
Custom Action
14) a)ASP Objects
Request Object
Response Object
Server Object
Session Object
Application Object
Definition
Properties
Methods
P.SARANYA,AP/IT 80
Severs
Event handlers
Collections
14 b)i)
Create your HTML button.
Create some Javascript.
Use your VBScript code to write a value to the button's "onClick" function.
ii) Cookies
Definition
Advantages of cookies
Disadvantage of cookies
Creating a cookie
Retrieving a cookie
Example
15)a) .NET is a Microsoft framework.
Explanation
.NET architecture
Technology components:
Development tools.
Specialized servers.
Web services.
Devices.
The .Net platform consists of five main components:
Operating system layer.
.NET building block services.
.NET framework.
.NET servers
Visual Studio .NET.
Common Language Runtime(CLR)
15. b)i) Payroll processing using C# .Net
P.SARANYA,AP/IT 81
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string name;
int employeeNumber;
double hours;
const double hourlyWage = 7.5;
double gross;
double tax;
double insurance;
double deduction;
private void btnCompute_Click(object sender, EventArgs e)
{
if (txtName.Text == "")
{
MessageB.Text = "...";
}
else if (txtPNumber.Text.Length <= 8)
P.SARANYA,AP/IT 82
{
MessageB.Text = "...";
}
else if (txtHoursWork.Text == "")
{
MessageB.Text = "...";
}
else if (btnCompute.Text == "Compute")
{
name = txtName.Text;
employeeNumber = Convert.ToInt32(txtPNumber);
hours = Convert.ToDouble(txtHoursWork.Text);
gross = hours * hourlyWage;
txtGrossPay.Text = "£" + Convert.ToString(gross);
tax = gross / 100 * 20;
txtIncomeTax = "£" + Convert.ToString(tax);
insurance = gross / 100 * 7;
txtNI = "£" + Convert.ToString(insurance);
deduction = tax + insurance;
txtTotalDeduction = "£" + Convert.ToString(deduction);
}
else
{
txtName.Text = "";
txtPNumber.Text = "";
txtHoursWork.Text = "";
txtGrossPay.Text = "";
txtIncomeTax.Text = "";
P.SARANYA,AP/IT 83
txtNI.Text = "";
txtTotalDeduction.Text = "";
btnCompute.Text = "Compute";
}
}
private void button1_Click(object sender, EventArgs e)
{
Close();
}
}}
15b)ii) Sort an array of integers
using System;
class Program
{
static void Main()
{
int[] values = { 4, 7, 2, 0 };
Array.Sort(values);
foreach (int value in values)
{
Console.Write(value);
Console.Write(' ');
}
Console.WriteLine();
}
}
P.SARANYA,AP/IT 84
B.E/B.Tech DEGREE EXAMINATION APRIL/MAY 2008
Eighth semester
Information Technology
IT 1451-WEB TECHNOLOGY
(Regulation 2004)
Time: 3 hours Maximum marks: 100
Answer ALL questions
PART –A
1. What are the two major protocols for accessing email from servers.
2. Define frameset.
3. What is the important feature of dynamic positioning?
4. List the possible opacity attributes of dynamic positioning.
5. Write some commonly used video file formats.
6. Explain the difference between get request and post request type.
7. What is XSL and why it is used.
8. Explain cookies.
9. What are the types of directives in JSP.
10. When it is useful to redirect a request to a different resource.
PART –B
11. a) i. Describe the java script global functions in detail.
ii. Use a one dimensional array and write a script to solve the following problem. Read in 20
numbers, each of which is between 10 and 100. As each number is read , print it only if it is not a
duplicate of a number that has already been read.
Or
b) Write a script that inputs a telephone number as a string in the form (555)555-555. The script
should use strings method split to extract the area code as token and the last four digits of the phone
numbers as a token. Display the area code in one test field and the seven digit phone number in
another text field.
13. a) i. Describe the system architecture of a multi-tier application.
14. a) How document manipulation is done with XML document object module and explain in
detail the various methods of DOM.
P.SARANYA,AP/IT 85
Or
b)i. Explain session tracking. How it provides personalized services to consumers.
ii. Describe the features of ASP with examples.
15).a)i. Describe the servlet architecture and the various interfaces invoked by the servlet container
ii. Write a servlet program that handles HTTP get request containing data that is supplied by the
user as a part of the request.
Or
b).i. What does JSP scripting component include. Explain with a program.
ii. Describe JSP standard actions. How does standard actions provide JSP implementers with access
to several of the most common tasks performed in JSP.
PART –A
1. The two major protocols used for email are SMTP(Simple mail transfer Protocol),POP(Post
Office Protocol).
2. The <frameset> tag defines a frameset.
The <frameset> element holds one or more <frame> elements. Each <frame> element can hold
a separate document.
3. Dynamic positioning provides several advantages over simply manipulating the normal flow of
the page
The actual position of content can be determined with precision. The content does not have
to be distorted to fit into complex table structures.
Content can be rendered visible or invisible, allowing for dynamic effects that lend
themselves to scripting.
Content can be layered, so that more than one item appears in the same location on a page.
4. The value of the position attribute can be:
absolute
fixed
relative
static
inherit
5. Commonly used video file formats are .wmv, .avi, .mp4, .mpeg, .mpg, .mov, etc.
P.SARANYA,AP/IT 86
6. In GET your entire form submission can be encapsulated in one URL, like a hyperlink. query
length is limited to 255 characters, not secure, faster, quick and easy. The data is submitted as
part of URL.In POST data is submitted inside body of the HTTP request. The data is not visible
on the URL and it is more secure.
7. eXtensible Stylesheet Language(XSL) deals with most displaying the contents of XML
documents.XSL consists of three parts:
XSLT - a language for transforming XML documents
XPath - a language for navigating in XML documents
XSL-FO - a language for formatting XML documents
7. Cookies are text files that store information about the user by which the web server identifies
and marks each different visitor to a web site and determines where a user has been before. A
cookie can store information only when the user sends it.
8. Types of JSP directives
Page Directive
Include Directive
Tag Library directive
9. The JSP standard actions affect the overall runtime behavior of a JSP page and also the response
sent back to the client. They can be used to include a file at the request time, to find or
instantiate a JavaBean, to forward a request to a new page, to generate a browser-specific code,
etc.
PART B
11. a)i. Java script Global functions
Explanation
Properties
Methods
Example
ii Program
<script type = "text/javascript">
function read_num()
{
var num = new Array();
P.SARANYA,AP/IT 87
for (var y=0; y<20; y++)
{
num[y]=prompt("Enter a number", "");
if (num[y] >=10 && num[y] <= 100){
document.writeln( num[y] + "<br />");
}}}
</script>
b.
<script type="text/javascript">
var p=window.prompt("Enter the phone in the form (XXX)XXX-XXXX","");
var code=p.split(")")[0].split("(")[1];
var p1=p.split(")")[1].split("-")[0];
var p2=p.split(")")[1].split("-")[1];
document.write("<form>");
document.write("Code: <input type=\"text\" name=\"code\" value=" + code + "><br/>");
document.write("Phone: <input type=\"text\" name=\"phone\" value=" + p1 + p2 +"><br />");
document.write("</form>");
</script>
13. Multi-tier architecture
Definition
Explain each tier
Entity Tier
Business Tier
Data Tier
Diagram
14. a. Document Object Model
Definition
List some methods in DOM
Explain any 6 methods
Explain it with an example.
b. i. Session tracking
Definition for session tracking
Explain the 5 different mechanisms for session tracking:
P.SARANYA,AP/IT 88
User Authorization
Hidden fields
URL rewriting
Cookies
Session tracking API.
ii. ASP features
ASP Object
ASP Object Overview
ASP Create an Object - Server.CreateObject
ASP Object Properties
ASP Object Methods
Example
15. a i. Servlet architecture
Servlet architecture made by two packages :
javax.servlet.Servlet
javax.servlet.http
It consist of one basic interface and 2 abstract classes, they are :
Servlet Interface
GenericServlet Abstarct Class
HttpServlet Abstarct Class
The Servlet interface defines 5 methods. The main 3 most important are :
init() - Initializes a servlet
service() - Receives and responds to Client requests
destroy() - Perform cleanup operation
The two methods throws Exceptions :
void init( ServletConfig config ) throws ServletException
void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException
Servlet Architecture diagram
ii. Sample program for servlet using request & response interface.
import javax.servlet.*;
P.SARANYA,AP/IT 89
import javax.servlet.http.*;
import java.io.*;
public class WelcomeServlet2 extends HttpServlet {
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException
{
String firstName = request.getParameter( "firstname" );
response.setContentType( "text/html" );
PrintWriter out = response.getWriter();
out.println( "<?xml version = \"1.0\"?>" );
out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD "+"XHTML 1.0 Strict//EN\"
\"http://www.w3.org" +"/TR/xhtml1/DTD/xhtml1-strict.dtd\">" );
out.println( "<html xmlns = \"http://www.w3.org/1999/xhtml\">" );
out.println( "<head>" );
out.println("<title>Processing get requests with data</title>" );
out.println( "</head>" );
out.println( "<body>" );
out.println( "<h1>Hello " + firstName + ",<br />" );
out.println( "Welcome to Servlets!</h1>" );
out.println( "</body>" );
out.println( "</html>" );
out.close();
}
b. i. JSP component architecture
Directive elements
Page Directive
Include Directive
Tag Library directive
Scripting element
Declaration
Expression
P.SARANYA,AP/IT 90
Scriplet
Action elements
Standard Action(Forward,Include,Use Bean)
Custom Action
ii. Standard action elements
The standard actions available in JSP are as follows(explain any 4 with example)
<jsp:include>
<jsp:forward>
<jsp:useBean>
<jsp:setProperty>
<jsp:getProperty>
<jsp:param>
<jsp:plugin>