CLASS : TE A & B SEM :V
SUBJECT : INTERNET PROGRAMMING LAB CODE :CSDLO5012
OBJECTIVES:
The student should be made to:
∙ To understand different Internet Technologies.
∙ To learn java-specific web services architecture
UNIT I WEBSITE BASICS, HTML 5, CSS 3, WEB 2.0 9 Web Essentials: Clients, Servers and
Communication – The Internet – Basic Internet protocols – World wide web – HTTP Request
Message – HTTP Response Message – Web Clients – Web Servers – HTML5 – Tables – Lists –
Image – HTML5 control elements – Semantic elements – Drag and Drop – Audio – Video controls
– CSS3 – Inline, embedded and external style sheets – Rule cascading – Inheritance – Backgrounds
– Border Images – Colors – Shadows – Text – Transformations – Transitions – Animations.
UNIT II CLIENT SIDE PROGRAMMING 9 Java Script: An introduction to JavaScript–
JavaScript DOM Model-Date and Objects,-Regular Expressions- Exception Handling-Validation
Built-in objects-Event Handling- DHTML with JavaScript- JSON introduction – Syntax – Function
Files – Http Request – SQL.
UNIT III SERVER SIDE PROGRAMMING 9 Servlets: Java Servlet Architecture- Servlet Life
Cycle- Form GET and POST actions- Session Handling- Understanding Cookies- Installing and
Configuring Apache Tomcat Web Server DATABASE CONNECTIVITY: JDBC perspectives,
JDBC program example – JSP: Understanding Java Server Pages-JSP Standard Tag Library
(JSTL)-Creating HTML forms by embedding JSP code.
UNIT IV PHP and XML 9 An introduction to PHP: PHP- Using PHP- Variables- Program control
Built-in functions- Form Validation- Regular Expressions – File handling – Cookies – Connecting
to Database. XML: Basic XML- Document Type Definition- XML Schema DOM and Presenting
XML, XML Parsers and Validation, XSL and XSLT Transformation, News Feed (RSS and
ATOM).
UNIT V INTRODUCTION TO AJAX and WEB SERVICES 9 AJAX: Ajax Client Server
Architecture-XML Http Request Object-Call Back Methods; Web Services: Introduction- Java web
services Basics – Creating, Publishing, Testing and Describing a Web services (WSDL)-Consuming
a web service, Database Driven web service from an application –SOAP.
2 V- SEM
OUTCOMES:
At the end of the course, the students should be able to:
∙ Construct a basic website using HTML and Cascading Style Sheets.
∙ Build dynamic web page with validation using Java Script objects and by applying
different event handling mechanisms.
∙ Develop server side programs using Servlets and JSP.
∙ Develop server side programs using JSP.
∙ Construct simple web pages in PHP and to represent data in XML format.
∙ Use AJAX and web services to develop interactive web applications
TEXT BOOK:
1. Deitel and Deitel and Nieto, ―Internet and World Wide Web – How to Program‖, Prentice
Hall, 5th Edition, 2011.
REFERENCES:
1. Stephen Wynkoop and John Burke ―Running a Perfect Website‖, QUE, 2nd Edition,1999. 2.
Chris Bates, Web Programming – Building Intranet Applications, 3rd Edition, Wiley
Publications, 2009.
3. Jeffrey C and Jackson, ―Web Technologies A Computer Science Perspective‖, Pearson
Education, 2011.
4. Gopalan N.P. and Akilandeswari J., ―Web Technology‖, Prentice Hall of India,
2011. 5. UttamK.Roy, ―Web Technologies‖, Oxford University Press, 2011.
COURSE OUTCOME
CO1 Construct a basic website using HTML and Cascading Style Sheets.
CO2 Build dynamic web page with validation using Java Script objects and by
applying different event handling mechanisms.
CO3 Develop server side programs using Servlets and JSP.
CO4 Develop server side programs using JSP.
CO5 Construct simple web pages in PHP and to represent data in XML format.
CO6 Use AJAX and web services to develop interactive web applications
UNIT I WEBSITE BASICS, HTML 5, CSS 3, WEB 2.0
Web Essentials: Clients, Servers and Communication – The Internet – Basic Internet protocols –
World wide web – HTTP Request Message – HTTP Response Message – Web Clients – Web
Servers – HTML5 – Tables – Lists – Image – HTML5 control elements – Semantic elements – Drag
and Drop – Audio – Video controls – CSS3 – Inline, embedded and external style sheets – Rule
cascading – Inheritance – Backgrounds – Border Images – Colors – Shadows – Text –
Transformations – Transitions – Animations.
PART – A
1. What are Clients and Servers? (U)
The client machine (or the client process) makes the request for some resource or service, and the
server machine (the server process) handles the request and sends the response (result) back to
the client.
2. Mention the characteristics of RIA.(R)
✔ Responsiveness
✔ Rich User Interface
✔ Direct interaction
✔ Partial-page updating
✔ Better feedback
✔ Consistency of look and feel
✔ Offline use
✔ Performance impact
3. List few technologies of RIA. (R)
✔ HTML5 + CSS3 + JavaScript + JavaScript frameworks
✔ Ajax
✔ Dojo
✔ Flex
✔ Silverlight
✔ JavaFX
✔ Ruby on Rails
✔ JavaServer Faces
✔ ASP.NET Ajax
4. What are the benefits of RIA? (U)
1.Increased productivity
2.Improving customer loyalty
3.Increase in new customers
4
4.Reduced operational costs
5.Installation is not required
6.Easy to upgrade
7.Easily made available over internet / intranet
8.Richer UI
9.More responsive UI
10. Client / Server Balance
11. Asynchronous communication
12. Network efficiency
5. Define Internet.(R)
Internet is the network of networks connected via the public backbone and communicating using
TCP/IP communication protocol. Internet is a network of interconnected computers that is now
global.
6. What is meant by website? (U)
A website is a set of pages of information on the internet about a particular subject, published
by a single person or organization.
7. What is meant by web server? (U) (APRIL/MAY 2021, 2022) A web server is a computer
system or program that sends websites and information to internet users.
Various functions of web server are:-
1. The web server accepts the requests from the web browsers.
2. The user request is processed by the web server.
3. The web server respond to the users by providing the services requested.
8. What is meant by web client? (U) (APRIL/MAY 2022) A web client is an application that
communicates with a web server, using Hypertext Transfer Protocol (HTTP). The web browser
is an example of a web client.
9. Write the function of a Web Server. (U) (MAY / JUNE 2014) Various functions of
web server are:-
1. The web server accepts the requests from the web browsers.
2. The user request is processed by the web server.
3. The web server respond to the users by providing the services requested.
10. List any four common browsers. (R) (NOV / DEC 2011) (i) Internet Explorer
(ii) Mozilla Firefox
(iii) Opera
5
11. Differentiate websites and web server. (AN)
Website Web server
A website is a set of linked documents The web server on the other side is a
associated with a particular person, computer program, which delivers content,
organization or topic that is held on a such as websites or web pages, for
computer system and can be accessed as example, over the world wide web from a
part of the world wide web. web server to your computer.
12. Define Protocol and list various types of protocols. (R) (MAY/JUNE 2013) Protocol is
a set of rules and regulations which should be obeyed by both sender and receiver for
data communication.
✔ TCP/IP - Transmission Control Protocol/Internet Protocol – Connection Oriented
Protocol
✔ HTTP – Hypertext Transfer Protocol – Connection Oriented Protocol
✔ FTP – File Transfer Protocol - Connection Oriented Protocol
✔ POP3 – Post Office Protocol – Connection Oriented Protocol
✔ SMTP – Simple Mail Transfer Protocol –
✔ Telnet Protocol – Used in Remote Login System
✔ UDP – User Datagram Protocol- Connectionless Protocol
Note: POP3 and SMTP protocols are used only in email-generation.
13. Give the difference between Internet and Intranet. (AN)
(NOV/DEC 2015, NOV/DEC 2016)
Internet Intranet
Internet is network of Computers Intranet is network of Computers
which is open for all. designed for a specific group of users.
Internet itself contains a large Intranet can be accessed from
number of intranets. Internet but with restrictions.
Unlimited number of users. Limited number of Users.
Visitors traffic is unlimited. Limited visitors traffic.
Contains unlimited source of information. Contains only specific group
purpose information.
Collection of various LANs, WANs Mostly any of LAN or MAN or WAN.
and MANs.
14. Define WWW. (R)
∙ WWW means World Wide Web – It is a collection of software and corresponding
protocols used to access the resources over the network. It is used to connect wide area
network.
∙ WWW contains huge amount of documents, images and other resources which can
be accessed using the hyperlinks. Thus the internet can be used through the web.
15. What is meant by Domain Name Service? (U)
Domain Name System (or Service or Server), is an Internet service that translates domain
names into IP addresses. Because domain names are alphabetic, they're easier to remember.
The Internet however, is really based on IP addresses. Every time you use a domain name,
therefore, a DNS service must translate the name into the corresponding IP address. For
example, the domain name www.example.com might translate to 198.105.232.4.
16. State the function of DNS. (R) (NOV / DEC 2012) Domain Name Service (DNS) is the service
used to convert human readable names of hosts to IP addresses. The main function of DNS is
name resolution. Name resolution is the process of mapping a domain name to an IP address.
17. Define URI. (R) (APRIL / MAY 2011) The Uniform Resource Identifier(URI) is a
string used to identify the resources on the internet. The URI is a combination of
URL and URN.
Syntax:
Scheme: //authority/path?query
18. What is URL? Give its syntax. (U)
URL means Uniform Resource Locator. It is used to identify the resource with its location.
The resource can be a file, directory, HTML page, image, program, and so on. The URL
consists a number of pieces like protocol, hostname, path, query string, etc. The syntax of
URL is
Protocol: //username@hostname:port/path/filename#fragment?query
Example: http://www.example.org:5678/a/b/c.txt?t=win&s=chess#para5
19. What is meant by absolute URLs? (U)
An absolute URL contains all the information necessary to locate a resource. An absolute
URL uses the following format:
scheme://server/path/resource
scheme – Specifies how the resource is to be accessed.
server - Specifies the name of the computer where the resource is located. path - Specifies
the sequence of directories leading to the target. If resource is omitted, the target is the last
directory in path.
resource - If included, resource is the target, and is typically the name of a file. It may be a
simple file, containing a single binary stream of bytes, or a structured document, containing one or
more storages and binary streams of bytes.
20. What do you mean by Relative URLs? (May / June 2014)(U)A relative URL locates
a resource using an absolute URL as a starting point. In effect, the "complete URL" of the target is
specified by concatenating the absolute and relative URLs. A relative URL typically consists only
of the path, and optionally, the resource, but no scheme or server i.e. Relative URLs are a way to
identify a resource relative to their context.
Example:
Relative URL Absolute URL
d/e.html http://www.example.org/a/b/d/e.html
21. What do you mean by HyperText Transfer Protocol (HTTP)? (U)
HTTP is an asymmetric request-response client-server protocol. An HTTP client sends a request
message to an HTTP server. The server, in turn, returns a response message. HTTP is a stateless
protocol. In other words, the current request does not know what has been done in the previous
requests.
22. What do you mean by HTTP Message? (U)
HTTP messages are how data is exchanged between a server and a client. There are two types of
messages: requests sent by the client to trigger an action on the server, and responses, the answer
from the server. HTTP messages are composed of textual information encoded in ASCII, and
span over multiple lines. An HTTP message consists of a message header and an optional
message body, separated by a blank line, as illustrated below:
23. Write the format of HTTP Request Message. (R)
The format of an HTTP request message is as follow:
Request Line
The first line of the header is called the request line, followed by optional request
headers. The request line has the following syntax:
request-method-name request-URI HTTP-version
▪ request-method-name: HTTP protocol defines a set of request methods, e.g., GET, POST,
HEAD,and OPTIONS. The client can use one of these methods to send a request to the
server.
▪ request-URI: specifies the resource requested.
8
V-SEM CSMIT
▪ HTTP-version: Two versions are currently in use: HTTP/1.0 and HTTP/1.1.
Request Headers
The request headers are in the form of name:value pairs. Multiple values, separated by commas, can
be specified.
request-header-name: request-header-value1, request-header-value2, ...
24. Write the format of HTTP Response Message. (R)
The format of the HTTP response message is as follows:
Status Line
The first line is called the status line, followed by optional response header(s).
The status line has the following syntax:
HTTP-version status-code reason-phrase
▪ HTTP-version: The HTTP version used in this session. Either HTTP/1.0 and HTTP/1.1. ▪ status code: a 3-digit
number generated by the server to reflect the outcome of the request. ▪ reason-phrase: gives a short explanation
to the status code.
▪ Common status code and reason phrase are "200 OK", "404 Not Found", "403 Forbidden", "500
Internal Server Error". 9
V-SEM CSMIT
Response Headers
The response headers are in the form name:value pairs:
response-header-name: response-header-value1, response-header-value2, ...
25. What is HTML?(U)
HTML is a markup language for describing web documents (web pages).
∙ HTML stands for Hyper Text Markup Language
∙ A markup language is a set of markup tags
∙ HTML documents are described by HTML tags
∙ Each HTML tag describes different document content
26. What is HTML5?(U)
HTML5 is a next version of HTML that provides new features which will make HTML much
easier. These new introducing features make your website layout clearer to both website
designers and users. There are some elements like <header>, <footer>, <nav> and <article>
that define the layout of a website.
27. Mention some advantages of using HTML5.(AN)
a. It is enriched with advance features which makes it easy and interactive for
designer/developer and users.
b. It allows the user to play a video and audio file.
c. It allows us to draw on a canvas.
d. It facilitates to design better forms and build web applications that work offline. e. It
provides advance features for that we would normally have to write JavaScript to do.
28. List some of the newly added tags of HTML5.(R)
Tag Description
<audio> It is used to play audio file in HTML.
<canvas> It is used to draw canvas.
<data> It provides machine readable version of its data.
<dialog> It defines a window or a dialog box.
<figcaption> It is used to define a caption for a <figure> element. It
defines a self-contained content like photos, diagrams etc. It defines
<figure>
<footer> a footer for a section.
<header> It defines a header for a section.
<main> It defines the main content of a document.
<mark> It specifies the marked or highlighted content.
<menuitem> It defines a command that the user can invoke from a popup
menu.
10
<nav> It is used to define the navigation link in the
<progres document. It specifies the progress of the task.
s> It defines a section in the document.
<section <summary> It specifies a visible heading for
> <detailed> element. It is used to define a date/time.
It is used to play video file in HTML.
<time> It defines a possible line break.
<video>
<wbr>
29. List the types of Lists in HTML. (R)
▪ Unordered: A bullet list
▪ Ordered: A numbered list
30. What are Semantic Elements in HTML5? (U)
A semantic element clearly describes its meaning to both the browser and the developer.
Examples of non-semantic elements: <div> and <span> - Tells nothing about its
content. Examples of semantic elements: <form>, <table>, and <article> - Clearly
defines its content.
31. How will you add image in HTML 5? (A)
The <img> tag defines an image in an HTML page.
The <img> tag has two required attributes: src and alt.
The following attributes: align, border, hspace, and vspace are not supported in
HTML5. <img src="smiley.gif" alt="Smiley face" height="42" width="42">
32. How will you create lists in HTML 5? (A)
1. Designate the beginning of the list with <ul> or <ol>.
The <ul> tag indicates an unordered (bullet) list, and the <ol> tag describes an ordered
(numbered) list.
2. Surround each item in the list with an <li></li> pair.
Example:
<ol>
<li>one</li>
<li>two</li>
<li>three</li>
</ol>
33. What is the use of Drag and drop property in HTML5? (U)
Drag and Drop (DnD) is powerful User Interface concept which makes it easy to copy, reorder
and deletion of items with the help of mouse clicks. This allows the user to click and hold the
mouse button down over an element, drag it to another location, and release the mouse button to
drop the element there.
11
34. How to insert Audio & Video in HTML5? (A)
The HTML5 <audio> and <video> tags make it simple to add media to a website. Its need to set
src attribute to identify the media source and include a controls attribute so the user can play and
pause the media.
Embedding Video
Most commonly used video formats are −
∙ Ogg − Ogg files with Thedora video codec and Vorbis audio codec.
∙ mpeg4 − MPEG4 files with H.264 video codec and AAC audio codec.
<source> tag is used to specify media along with media type and many other attributes. A video
element allows multiple source elements and browser will use the first recognized format.
<video width = "300" height = "200" controls
autoplay> <source src = "/html5/foo.ogg" type ="video/ogg"
/> <source src = "/html5/foo.mp4" type = "video/mp4" />
Your browser does not support the <video> element.
</video>
Embedding Audio
Most commonly used audio formats are ogg, mp3 and wav.
We can use <source&ggt; tag to specify media along with media type and many other attributes. An
audio element allows multiple source elements and browser will use the first recognized format.
<audio controls autoplay>
<source src = "/html5/audio.ogg" type = "audio/ogg" />
<source src = "/html5/audio.wav" type = "audio/wav" /> Your
browser does not support the <audio> element. </audio>
35. List out the Video/Audio Attributes in HTML5. (R)
Video Attributes & Description
✔ autoplay - This Boolean attribute if specified, the video will automatically begin to play
back as soon as it can do so without stopping to finish loading the data.
✔ autobuffer - This Boolean attribute if specified, the video will automatically begin buffering
even if it's not set to automatically play.
✔ Controls - If this attribute is present, it will allow the user to control video playback,
including volume, seeking, and pause/resume playback.
✔ Height - This attribute specifies the height of the video's display area, in CSS pixels. ✔
Loop - This Boolean attribute if specified, will allow video automatically seek back to the start
after reaching at the end.
✔ Preload - This attribute specifies that the video will be loaded at page load, and ready to run.
Ignored if autoplay is present.
✔ Poster - This is a URL of an image to show until the user plays or seeks.
12
V-SEM
✔ Src - The URL of the video to embed. This is optional; you may instead use the <source>
element within the video block to specify the video to embed.
✔ Width - This attribute specifies the width of the video's display area, in CSS pixels.
Audio Attributes & Description
✔ Autoplay - This Boolean attribute if specified, the audio will automatically begin to play
back as soon as it can do so without stopping to finish loading the data.
✔ Autobuffer - This Boolean attribute if specified, the audio will automatically begin
buffering even if it's not set to automatically play.
✔ Controls - If this attribute is present, it will allow the user to control audio playback,
including volume, seeking, and pause/resume playback.
✔ Loop - This Boolean attribute if specified, will allow audio automatically seek back to the
start after reaching at the end.
✔ Preload - This attribute specifies that the audio will be loaded at page load, and ready to run.
Ignored if autoplay is present.
✔ Src - The URL of the audio to embed. This is optional; you may instead use the <source>
element within the video block to specify the video to embed.
36. What is XHTML? (U)
XHTML stands for EXtensible HyperText Markup Language which is almost identical to
HTML and is stricter than HTML.
37. Differentiate HTML and XHTML. (AN)
HTML XHTML
Introduction HTML or HyperText XHTML (Extensible
Markup Language is the HyperText Markup
main markup language for Language) is a family of
creating web XML markup
pages and other information languages that
that can be displayed in a mirror or extend versions of
web browser. the widely used Hypertext
Markup Language (HTML),
the language in which web
pages are written.
Filename extension .html, .htm .xhtml, .xht, .xml, .html, .htm
Internet media type text/html application/xhtml+xml
Developed by W3C & WHATWG World Wide Web Consortium
Type of format Document file format Markup language
Extended from SGML XML, HTML
Stands for HyperText Markup Language Extensible HyperText Markup
Language
Application Application of Standard Application of XML
Generalized Markup Language
(SGML).
Function Web pages are written in HTML. Extended version of HTML
that is stricter and XML-
based.
Nature Flexible framework Restrictive subset of XML
requiring lenient HTML and needs to be parsed with
specific parser. standard XML parsers.
Origin Proposed by Tim Berners- World Wide Web Consortium
Lee in 1987. Recommendation in 2000.
Versions HTML 2, HTML 3.2, XHTML 1, XHTML 1.1,
HTML 4.0, HTML 5. XHTML 2, XHTML 5.
38. Define Cascading Style sheet? (R) (MAY/JUNE 2013) The Cascading Style Sheet is a markup
language used in the web document for presentation purpose. The primary intension of CSS is
to separate out the web content from the presentation. This separation of structure from
presentation simplifies maintaining and modifying a document‟s layout.
39. Mention the need for Cascading Style Sheets. (U) (APRIL/ MAY 2011) Give
some advantages of using CSS. (NOV/DEC 2013)
(1) CSS allows the separation between the information contained in a document and its
presentation.
(2) Any change in the presentation can be made without disturbing the information of the
document.
(3) CSS allows developers to give the consistent appearance to all elements of the web page.
40. Give the syntax of a CSS rule. (R) (NOV/DEC 2011, MAY/JUNE 2012) A CSS
style sheet consists of one or more style rules called rulesets.
Each rule set consists of two parts:
1 Selector string
2 Declaration block
P{
Property names declarationsfont-size :
Background-color : yellow
x-large
Selector String Declaration block
41. What is Selector Strings? Explain its types.(U)
The selector string indicates the elements to which the rule should apply, and each
declaration within the declaration block specifies a value for one style property of those
elements.
⮚ Single element selector strings
▪ It contains a single selector string eg.
▪ h1 {text-align:center}
⮚ Multiple selector strings
▪ h1,h2,h3,h4,h5,h6 {text-align:center}
▪ Where h1to h6 gives same output.
⮚ Universal selector
▪ *{font-weight:bold}
▪ Universal selector applies to whole document by default
⮚ Specific elements by id
▪ #id1,#id2 {font-style: italic}
▪ This can be used as follows in html program
▪ <h1 id="id1"> About Panimalar </h1>
▪ <h2 id="id2"> Welcome </h2>
⮚ Specific element by class selector
▪ /* class Selector */
▪ .class1 {font-variant: Big-caps}
This can be used as follows in html program
o <p id="id1" class ="class1"> Panimalar Engineering College </p>
42. What are the different types of style sheets? (U)
1. Inline style sheet
2. External style sheet
3. Embedded style sheet
43. List the different <style> tag Font Attributes. (R)
FONT ATTRIBUTES:
Attribute Values
Name
Font-family A comma-delimited sequence of font family names (Serif, sanserif, cursive)
Font-style Normal, italic or oblique.
Font-size A term that denotes absolute size (xx-small, x-small, small, medium, large,
x large, xx-large), relative size (larger, smaller), a number (of pixels),
percentage (of the parent element‟s size
Font-weight Normal, bold, lighter, or one of the nine numerical values (100,200 to 900)
15
44. List the different <style> tag color and background attributes. (R)
Attributes Values
Color Sets an element‟s text-color- a color name or a color code
Backgroun Specifies the color in an element‟s background. A color name or a color code.
d color
Backgroun Sets the background image. A URL or none.
d image
Backgroun Within the background image specified, sets up how the image repeats
d repeat throughout the page. Repeat-x (repeats horizontally), repeat-y(repeats
vertically), repeat(both), no-repeat.
45. List the different <style> tag text attributes. (R)
Attributes Values
Text Adds decoration to an element‟s text- none, underline, overline,
decoration line through, blink
vertical-align Determines an element‟s vertical position. Baseline, sub, super, top, text
top, middle, bottom, text-bottom, also percentage of the element‟s
length.
Text Applies a transformation to the text. Capitalize (puts the text into
transform initial caps), uppercase, lowercase or none.
text-align Aligns text with an element. Left, right, center, or justify can be given.
text-indent Indents the first line of text. A percentage of the element‟s width or a length.
46. List the different <style> tag Border attributes.(R)
Attributes Values
Border-style Solid, double, groove,
ridge, inset, outset
Border-color A color name or color code
Border-width Thin, medium thick or length
Border-top Thin, medium thick or length
width
Border Thin, medium thick or length
bottom
width
Border-left-width Thin, medium thick or length
Border-right Thin, medium thick or length
width
Border-top Specifies width, color and style
Border-bottom Specifies width, color and style
Border-left Specifies width, color and style
Border-right Specifies width, color and style
Border Sets all the properties at once
16
47. List the different <style> tag Margin attributes.(R)
Attributes Values
Margin-top Percent, length or auto
Margin-bottom Percent, length or auto
Margin-left Percent, length or auto
Margin-right Percent, length or auto
Margin Percent, length or auto
48. What are the advantages of CSS3 over CSS2? (AN)
1. CSS3 is divided into many different documents called Modules. Every module adds new
capability or extends features defined in CSS2 over preserving backward compatibility. Work
on CSS3 started around the time of publication of the original CSS2 recommendation.
2. Because of the modularization in CSS3, every modules has different stability and is in
different status.
3. The CSS3 version supports many more browsers than CSS2.
4. CSS3 has other added features such as new combinator, new CSS selectors, new pseudo
elements and new style properties
49. List out some of the new properties added in CSS3. (R)
Following is a list of CSS properties that were not defined in the CSS2.1
specification. ∙ animation
∙ background-clip
∙ background-origin
∙ background-size
∙ border-radius
∙ border-image
∙ box-decoration-break
∙ box-shadow
∙ box-sizing
∙ columns
∙ clear-after
∙ flex
∙ font-stretch
∙ font-size-adjust
∙ font-synthesis
∙ font-kerning
∙ font-variant-caps
∙ hanging-punctuation
∙ hyphens
∙ icon
∙ image-resolution
17
∙ image-orientation
∙ line-break
∙ object-fit
∙ object-position
∙ opacity
∙ outline-offset
∙ overflow-wrap / word-wrap
∙ backface-visibility
∙ perspective
∙ perspective-origin
∙ pointer-events (for HTML)
∙ resize
∙ tab-size
∙ text-align-last
∙ text-decoration-line
∙ text-decoration-skip
∙ text-decoration-position
∙ text-decoration-style
∙ text-emphasis
∙ text-justify
∙ text-orientation
∙ text-overflow
∙ transform
∙ transform-style
∙ text-shadow
∙ transition
∙ word-break
∙ word-spacing
∙ writing-mode
50. How does a Rich Internet Application (RIA) differ from a traditional web application?
(AN) (MAY/JUNE 2016)
Features Web applications RIAs
Rich User Experience N Y
Interactive, Responsive N Y
Low Maintenance Y Y
51. Write appropriate inline CSS to show a section of the HTML document with a font size of
20. (AP) (MAY/JUNE 2016) An inline CSS is used to apply a unique style to a single HTML
element.
An inline CSS uses the style attribute of an HTML element.
<!DOCTYPE html>
<html>
<head>
<title>HTML Inline CSS</title>
</head>
<body>
<p style="font-size:20px;">This is thick</p>
</body>
</html>
52. List out some of the shadow effects added in CSS3. (R)
CSS is used to add shadow to text and to elements. It has following
properties: ∙ text-shadow
∙ box-shadow
CSS Text Shadow
The CSS text-shadow property applies shadow to text.
In its simplest use, only specify the horizontal shadow (2px) and the vertical shadow (2px). To
add more than one shadow to the text, you can add a comma-separated list of shadows.
CSS Box Shadow
The box-shadow property attaches one or more shadows to an element.
53. List out some of the border images added in CSS3. (R)
CSS Border image property is used to add image border to some elements. A sample syntax of
boarder image is as follows –
#borderimg {
border: 10px solid transparent;
padding: 15px;
}
The most commonly used values are shown below –
border-image-source - Used to set the image path
border-image-slice - Used to slice the boarder image
border-image-width - Used to set the boarder image width
border-image-repeat - Used to set the boarder image as rounded, repeated and stretched
54. What is meant by transitions in CSS? (U)
The CSS transitions are effects that are added to change the element gradually from one style to
another, without using flash or JavaScript.
specify two things to create CSS transition.
o The CSS property on which you want to add an effect.
o The time duration of the effect.
It is used to add transition effect for more than one CSS property. If you want to add transition
effect on more than one property, separate those properties with a comma.
55. How to create CSS Animation? (C)
CSS Animation property is used to create animation on the webpage. It can be used as a
replacement of animation created by Flash and JavaScript. An animation makes an element change
gradually from one style to another. he animation could be bound to the selector by specifying at
least these two properties:
o The name of the animation
o The duration of the animation
CSS animation properties
@keyframes - It is used to specify the animation.
Animation - This is a shorthand property, used for setting all the properties, except the
animation-play-state and the animation-fill- mode property.
animation-delay - It specifies when the animation will start.
animation-direction - It specifies if or not the animation should play in reserve on alternate
cycle.
animation-duration - It specifies the time duration taken by the animation to complete one
cycle.
animation-fill-mode- it specifies the static style of the element. (when the animation is not
playing)
animation-iteration-count - It specifies the number of times the animation should be
played.
animation-play-state - It specifies if the animation is running or paused.
animation-name - It specifies the name of @keyframes animation.
animation-timing-function - It specifies the speed curve of the animation.
56. Define Transformation in CSS. List out its types. (R)
CSS3 supports transform property. This transform property facilitates you to translate, rotate,
scale, and skews elements. Transformation is an effect that is used to change shape, size and
position. There are two types of transforms:
CSS 2D Transforms
The CSS 2D transforms are used to re-change the structure of the element as translate,
rotate, scale and skew etc.
CSS 3D Transforms
The CSS 3D transforms facilitates you to move an element to X-axis, Y-axis and Z-axis.
Following is a list of 3D transforms methods:
57. Define rich internet application.(NOV/DEC 2016) (R)
A rich Internet application (RIA) is a Web application designed to deliver the same features and
functions normally associated with deskop applications. RIAs generally split the processing
across the Internet/network divide by locating the user interface and related activity and
capability on the client side, and the data manipulation and operation on the application server
side.
58. Give an example for inline style sheet. (R) (NOV/DEC 2018) An inline style may be used to
apply a unique style for a single element. To use inline styles, add the style attribute to the
relevant element. The style attribute can contain any CSS property. Example Inline styles are
defined within the "style" attribute of the relevant element:
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;text-align:center;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
59. Write about CSS Inheritance. (R)
The property value is inherited from the nearest ancestor element that has a value for the
property. If no ancestor has a value (or the property does not inherit) then CSS defines
an initial value that is used
Property values:
Specified
o Absolute
o Relative
Computed
Actual
60. What is Web 2.0 and give its example? (R) (APRIL/MAY 2021) A Web 2.0 website allows
users to interact and collaborate with each other through social media dialogue as creators of
user-generated content in a virtual community. This contrasts the first generation of Web 1.0-
era websites where people were limited to viewing content in a passive manner.
Examples of Web 2.0 features include social networking sites or social media sites (e.g.,
Facebook), blogs, wikis, folksonomies ("tagging" keywords on websites and links), video sharing
sites (e.g., YouTube), image sharing sites (e.g., Flickr), hosted services, Web applications
("apps"), collaborative consumption platforms, and mashup applications.
21
PART – B
1) Explain the following with an example :
a. Basic Internet Protocols b. World Wide Web (U)
2) Illustrate the te4chniques used to optimize website assets loading. (U) (APRIL/MAY 2022)
3) List and explain the various HTML elements in detail. (U)
(APRIL / MAY 2011, NOV / DEC 2013)
4) State the types of lists supported by HTML and explain them in detail. (U) 5) How do you create
frames? Why do we need them? Develop an application to explain the same. (C) 6) Explain the way
in which data can be presented in a tabular form using HTML. (U) 7) Develop a simple HTML
application using List, Tables, Frames, Images and Forms and explain in details of its every
attributes of respectively. (C)
8) Create a HTML document for a company home page and explain. (C) (MAY / JUNE 2013) 9)
Explain about the all CSS Styles and its Core Syntax with an example. (U) 10) Elaborate with
example the usage of CSS in HTML. (U) (NOV/DEC 2015) 11) List and explain in detail the
various selector strings. (U)
(APRIL / MAY 2011, MAY/JUNE 2012)
12) Explain the various types of Cascading Style Sheets with example. (U)
13) List and explain the various positioning schemes in detail. (Nov / Dec 2013) (U) 14) Explain
the seven values of position attributes that is used to position an HTML element. (U)
(APRIL/MAY 2022)
15) Explain the CSS box model in detail. (U) (MAY/JUNE 2012, NOV/DEC 2013) 16) Discuss on
(i) Web Servers (ii) XHTML. (U) (NOV/DEC 2015) 17) Explain about internet technologies in
detail. (U) (NOV/DEC 2016) 18) Write a XHTML program to display data in a table. (AP)
(NOV/DEC 2016) 19) Explain the three ways of inserting a CSS to a document with examples. (U)
(NOV/DEC 2016) 20) Discuss the structure of the HTTP request message. (U) (NOV/DEC 2018)
21) Explain about the XHTML DTD with an example. (U) (NOV/DEC 2018) 22) Explain the
significance of XHTML with the help of a real time application. Write
necessary code snippets. (U) (NOV/DEC 2018) 23) Discuss the functionalities of Webserver and
Web client in detail. (U) (NOV/DEC 2018) 24) Illustrate the different types of request methods of
http. Compare any two http request methods. 25) What do you mean by status code in http? (U)
(APRIL/MAY 2021) 26) Name all the modules which are used in the current version of CSS.
Distinguish between CSS2 and CSS3. What are the uses of an embedded style sheet? (AN)
(APRIL/MAY 2021)
UNIT – II CLIENT SIDE PROGRAMMING
Java Script: An introduction to JavaScript–JavaScript DOM Model-Date and Objects,-Regular
Expressions- Exception Handling-Validation-Built-in objects-Event Handling- DHTML with
JavaScript- JSON introduction – Syntax – Function Files – Http Request – SQL.
PART – A
1. What is JavaScript? (U)
JavaScript is a client-side scripting language which is to develop dynamic and interactive
web pages. It facilitates a programmer to design programs that enhance the functionality and
appearance of web pages.It is not an Object Oriented Language but it is an object based
language.
2. What is the purpose of Java Script? (U)
Two purpose of JavaScript:
⮚ It Introduces client-side scripting, which makes web pages more dynamic and interactive.
⮚ It provides the programming foundation for more complex server side scripting.
3. List out the some of the java script properties. (R)
JavaScript Properties are:
⬥ JavaScript code did not need to be compiled.
⬥ Interpreted vs. compiled languages:
Advantage: simplicity
Disadvantage: efficiency
⬥ JavaScript is a scripting language: designed to be executed within a larger software
environment
⬥ JavaScript can be run within a variety of environments like browser, web server,etc.
⬥ All data in JavaScript is an object or a property of an object.
4. Write a JavaScript program to display “welcome” message on the browser window. (C)
<!DOCTYPE html>
<html>
<head>
<title>This is a JavaScript example</title>
<script language="JavaScript">
document.write("Hello World!");
</script>
</head>
<body> Hello, User! </body>
</html>
5. Write a JavaScript program to display “welcome” message in the alert box. (C)
<!DOCTYPE html>
<html>
<head>
<title>This is a JavaScript example</title>
<script language="JavaScript">
Window.alert("Hello World!");
</script>
</head>
<body> Hello, User! </body>
</html>
6. Give the syntax to get input from the user in JavaScript. (R)
Prompt dialog - which allows the user to input a value that the script can use.
Syntax:
Variable = window.prompt(“message to be displayed”,”default value”);
Example:
var name = window.prompt(“Please Enter your name:”,”XXX”);
7. List out the java script built in Objects. (R) (MAY / JUNE 2012) ✔ The global Object
(window)
✔ String
✔ Number
✔ Boolean
✔ Date
✔ Math
✔ Array
8. What is Regular Expression in Java Script? How do you define RE? ( U) (APRIL/MAY
2022)
A regular expression is a certain way of representing a set of strings. Regular expressions
are frequently used to test that a string entered in an HTML form has a certain format or, in the
terminology of regular expressions, belongs to the set of string that have the correct format.
Syntax: /pattern/modifiers;
Example: var regexp=/^[0-9]+$/;
9. Give the syntax to handle exceptions in JavaScript. (R)
<script type="text/javascript">
<!--
try {
24
// Code to run
[break;]
} catch ( e ) {
// Code to run if an exception occurs
[break;]
}[ finally {
// Code that is always executed regardless of
// an exception occurring
}]
//-->
</script>
10. Define event programming. (R) (NOV / DEC 2015) Event-driven programming is a
programming paradigm in which the flow of the program is determined by events such as user
actions (mouse clicks, key presses), or messages from other programs/threads.
11. What is meant by intrinsic event handling? (U) (MAY / JUNE 2012) Intrinsic event handling
is a mechanism to attach specific scripts to your documents that are executed only when
something happens to an element.
∙ event - an action performed by the user, browser, or script
∙ event handler - JavaScript statements that execute when the event occurs
• An event is an occurrence of something potentially interesting to a script:
– Ex: mouseover and mouseout events
12. List some Intrinsic Event Attributes. (R) (APRIL/MAY 2011, NOV/DEC 2013)
Attribute When Called
Onload The body of the document has just been fully read and parsed by
the browser (this attribute pertains only do body and frameset)
Onunload The browser is ready to load a new document in place of the
current document (this attribute only pertains to body and
frameset)
Onclick The mouse button has been clicked and released over the element
ondblclick The mouse button has been double clicked and released over the element
onmousedown The mouse has been clicked over the element
onmouseup The mouse has been released over the element
onmouseover The mouse has just moved over the element
onmousemove The mouse has moved from one location to another over the element
onmouseout The element has just moved away from the element.
Onfocus The element has just to receive the keyboard focus (attribute pertains
only to certain element including a label.input, select, text area and
button)
Onblur The element has just lost the keyboard focus (attribute pertain only to the same
25
element as on focus
onkeypress This element has the focus and a key has been present and released
onkeydown This element has the focus and a key has been pressed and released
Onkeyup This element has the focus and a key has been released.
Onsubmit This element is ready to be submitted (applies only to form elements)
Onreset This element is ready to be reset (applies only to form elements)
onselelect Text in this element has been selected (highlighted) in preparation
for editing (applies only to input and text area element)
Onchange The value of this element has changed (applies only to input, text area
and select elements)
13. What do you mean by DOM Tree? Give an example. (U)
The documents in DOM are represented using tree like structure in which every element is
represented as a node. Such tree is called as DOM tree.
Exmaple:
Fig. HTML DOM Node Tree
23. What is JSON? Whether it is platform dependent? (U) (APRIL/MAY 2022) A
common use of JSON is to read data from a web server, and display the data in
a web page. o JSON stands for JavaScript Object Notation.
o JSON is lightweight data-interchange format.
o JSON is easy to read and write than XML.
o JSON is language independent.
o JSON supports array, object, string, number and values.
24. What are the features of JSON? (U)
1. Simplicity
2. Openness
3. Self-Describing
4. Internationalization
5. Extensibility
6. Interoperability
25. What is the syntax of JSON? (U)
JSON syntax is basically considered as a subset of JavaScript syntax; it includes the
following: ∙ Data is represented in name/value pairs.
∙ Curly braces hold objects and each name is followed by ':'(colon), the name/value pairs
are separated by , (comma).
∙ Square brackets hold arrays and values are separated by ,(comma).
26. List out the JSON Data types. (R)
In JSON, values must be one of the following data types:
∙ a string
∙ a number
∙ an object (JSON object)
∙ an array
∙ a boolean
∙ null
27. JSON Function Files
A common use of JSON is to read data from a web server, and display the data in a web
page. 1: Create an array of objects.
2: Create a JavaScript function to display the array.
3: Use an array literal as the argument (instead of the array variable):
4: Put the function in an external js file
28. What is the DOM used for? (U) (APRIL/MAY 2021) The Document Object Model (DOM)
is a programming interface for HTML and XML documents. It represents the page so that
programs can change the document structure, style, and content. The DOM represents the
document as nodes and objects. That way, programming languages can connect to the page.
29. What do you mean by exception handling? (U) (APRIL/MAY 2021) The Exception
Handling in Java is one of the powerful mechanism to handle the runtime errors so that normal
flow of the application can be maintained. Exception Handling is a mechanism to handle
runtime errors such as ClassNotFoundException, IOException, SQLException,
RemoteException, etc.
27
PART – B
1. Whether JavaScript a statically types or dynamically typed language. Justify your answer
with examples. (AN) (APRIL/MAY 2022) 2. Write a JavaScript program to add two integers.
Get the input from the user and display the result in pop-up box. (C)
3. Explain about DOM Nodes and Tress. (U)
4. Write JavaScript to find sum of first n even numbers and display the result. Get the value of
„n‟ from user. (C) (MAY/JUNE 2013) 5. Write JavaScript to find factorial of a given number.
(C)
6. Describe how do you use regular expression on java script for form validation? Develop a
complete application that would include functions to validate the user data. (C)
(MAY/JUNE2014)
7. Explain in detail about how the exceptions can be handled in JavaScript. (U) 8. Explain about
java script Built-in Objects. (U) (MAY / JUNE 2014) 9. Explain DOM Model and its
properties. (U) (NOV/DEC 2015, APRIL/MAY 2022) 10. Explain Document Tree with an
example. (U) (MAY/JUNE 2011, MAY/JUNE 2012) 11. Explain the DOM Event handling
with suitable example. (U)
(MAY/JUNE 2011, NOV/DEC 2011, MAY/JUNE 2012)
12. Use JavaScript and HTML to create a page with two panes. The first pane (on the left) should
have a text area where HTML code can be typed by the user. The pane on the right side
should display the preview of the HTML code typed by the user, as it would be seen on the
browser. (C) (MAY/JUNE 2016)
13. Write a DHTML program to handle the user click event. (C) (NOV/DEC 2016) 14.
Explain any two validation functions in Java script. (U) (NOV/DEC 2018) 15. Write a Java
script program to print prime numbers from 1 to 100. (U) (NOV/DEC 2018) 16. Explain the
concept of JSON with an example. (U) (NOV/DEC 2018) 17. What is the significance and
what are the benefits of including „Use strict‟ at the beginning
of a JavaScript source file? (U) (APRIL/MAY 2021) 18. Demonstrate use of JSON. How to
convert JavaScript objects to JSON ? List the benefits of JSON over XML. (A) (APRIL/MAY
2021) UNIT - III SERVER SIDE PROGRAMMING
Servlets: Java Servlet Architecture- Servlet Life Cycle- Form GET and POST actions- Session
Handling- Understanding Cookies- Installing and Configuring Apache Tomcat Web Server
DATABASE CONNECTIVITY: JDBC perspectives, JDBC program example – JSP:
Understanding Java Server Pages-JSP Standard Tag Library (JSTL)-Creating HTML forms by
embedding JSP code.
PART - A
1. What is a Servlet? (R)
Servlet is a server side programming language which is used for generating dynamic web
pages. It generates web-page as a response of the request received from client (browser).
2. List out the Advantages of Servlet. (R)
The advantages of Servlet are as follows:
i. Better performance: because it creates a thread for each request, not
process. ii. Portability: because it uses Java language.
iii. Robust: JVM manages Servlets, so we don't need to worry about the memory leak,
garbage collection, etc.
iv. Secure: because it uses java language.
3. What is Static webpage and Dynamic webpage? (R)
The webpages which are same for all the users are static webpages and the webpages that are
dynamically generated based on the user‟s request (that may be different for each user
depending on the request) are known as dynamic webpages. Servlet is mainly used for dynamic
webpages.
4. What is a web application? (R)
A web application is an application accessible from the web. A web application is composed of
web components like Servlet, JSP, Filter, etc. and other elements such as HTML, CSS, and
JavaScript. The web components typically execute in Web Server and respond to the HTTP
request.
5. What is a web application? (R)
Following the stages of servlet life cycle:
o Loading of Servlet class: The servlet container finds the servlet class mentioned in
web.xml file and loads it.
o Servlet instantiation: The object of servlet class gets created in this phase.
o Initialization: Servlet initialization by calling init() method.
o Servicing the request: In this phase the servlet service the client request by calling the
service() method.
29
o Destroy: Last phase of servlet life cycle. The destroy() method free up the servlet
instance so that it can be garbage collected.
6. Why Servlet is better than CGI? (U)
1) Servlet responses faster than CGI because it uses the multithreading concept to service
each request. CGI performance is not that good as it creates a new object for each request
while servlet allots a new thread for each request.
2) Learning and implementing servlet is quite easier compared to CGI.
3) Memory consumption is low in servlet compared to CGI.
7. What are Servlets? List its life cycle methods. (U)
(MAY / JUNE 2012, MAY / JUNE 2013) (APRIL/MAY 2021)
Servlets are Java programs which run inside a Servlet Container. A Servlet Container is
much like a Web Server which handles user requests and generates responses. Servlets extend
the server‟s functionality by allowing it to generate dynamic content.
Life cycle methods of a Servlet:
i. Init() – It performs servlet initialization tasks. This method is called when the servlet is
loaded in the memory for the first time.
ii. Service() – is a method actually called when an HTTP request is received; this method,
in turn, calls doGet(). Normally, you should not override service(). iii. Destroy() – method
will be called when the server is in the process of taking a servlet out of service, usually
when the server itself is shutting down.
8. Differentiate Client-Side Scripting and Sever-side Scripting. (AN)
S.No Server-Side Scripting Client-Side Scripting
1 It is used to create dynamic pages It is used when the browser already
based on browser request has all the code & the page is
altered on the basis of user input
2 Web server executes the server Web browser executes the client
side scripting side scripting
3 It is used to connect to the databases It cannot be used to connect to
on the web server the databases on the web server
4 Responses from server side scripts are Response from client side scripts
slower because the scripts are are faster because the scripts are
processed on remote computer processed on local computer
5 Examples: Servlets, JSP, PHP, Examples: JavaScript, VBScript
ASP, Ruby, Perl, Python
30
9. Difference between GenericServlet and HTTPServlet. (AN)
✔ GenericServlet is an abstract class which implements Servlet interface while HTTPServlet
abstract class extends the GenericServlet class. In short: GenericServlet class is a parent
class for HTTPServlet.
✔ GenericServlet does not support any protocol. HTTPSeervlet support HTTP and HTTPS
Protocol.
✔ GenericServlet cannot handle cookies and session while HTTPServlet can handle
them.GenericServlet class
10. What are the common HTTP request methods used for request-response between
browser and server? (U)
Method Description
GET Requests data from a specified resource
POST Submits data to be processed to a specified resource
HEAD Same as GET but returns only HTTP headers and no
PUT document body Uploads a representation of the specified
DELETE URI
OPTIONS Deletes the specified resource
Returns the HTTP methods that the server supports
CONNECT Converts the request connection to a transparent TCP/IP tunnel
11. Differentiate GET and POST method. (AN)
S.NO GET POST
1 Query String is part of URL Query String is sent as body of the
HTTP request
2 Length of the query string may be limited Length of the query string is unlimited
3 Recommended when parameter data is Recommended if parameter data is
not stored but used only to request intended to cause the server to update
information. Eg: Search Engine Query stored data. Eg: Online transaction
Query
4 The URL can be bookmarked or emailed Most browser will warn you if they are
and the same data will be passed to the about to resubmit POST data to avoid
server when the URL is revisited duplicate update
5 Eg: Eg:
<form name=”form1” method=”GET”> <form name=”form1” method=”POST”>
6 Servlet Method: Servlet Method:
doGet(HttpServletRequest req, doPost(HttpServletRequest req,
HttpServletResponse res){ } HttpServletResponse res){ }
31
12. What is ServletConfig? (R)
ServletConfig interface belongs to the package javax.servlet.ServletConfig. It is used for
passing the configuration parameters to the servlet. Servlet container instantiate it
implicitly.
13. What is ServletContext?(R)
Each web application has a common ServletContext. All the servlets in the web application can
access the ServletContext. It has the web-application information & resources which are
common and accessible to all the servlets present in the web application.
14. What is meant by a Session? (U)
A collection of HTTP requests to the server, all associated with a single session ID is known
as a Session. i.e Session means to time duration of the conversation held between the client and
the server. Session provides a way to identify a user across more than one page request or visit to
a Web site and to store information about that user. The session persists for a specified time
period, across more than one connection or page request from the user.
15. What is meant by Session Tracking or Session Handling? (U) (APRIL/MAY 2021,
2022) Session Tracking is the capability of a server to maintain the current state of a single
client‟s sequential requests. Using session tracking, we can keep track of previous session
(conversations) held between server and the browser by using session ID.
16. What is Session ID? (U)
Session ID is an unique identification number assigned by the server to each new HTTP
request for identifying them in subsequent conversations. It is used for sending all state
information to and fro between the browser and server.
17. What are the different techniques used for handling sessions? (R)
✔ Cookies
✔ Hidden Form Field
✔ URL Rewriting
✔ HttpSession
18. What are cookies? Give its uses. (U) (NOV/DEC 2015) A Cookie is a name-value pair of
information that a web server sends to a client machine as a part of an HTTP response. The
bowser then returns the cookie unchanged to the server to indicate the state of the conversation.
19. What is Servlet chaining? (R)
Servlet chaining is a concept where the request is processed in a chain of servlets. First
Servlet processes the request partially and passes to the second one, then second servlet
process it and passes to third one and so on. The last servlet returns the response to the client
(browser). 32
13. How Servlet maintains session using cookies?(U)
Cookie is a small piece of information, which is sent by a servlet to the Web browser. Cookies
gets stored in the browser and returned back to the server when needed. A cookie has a name,
a single value, and few other attributes.
14. What are Cookies?(R)
A cookie is a small text file that is stored in the client's machine, which will be send to the
server on each request. You can put your session data inside the cookie. The biggest problem
in using cookie is clients may disable the cookie.
15. How to create a cookie using servlet?(U)
Setting cookies with servlet involves three steps:
(1) Creating a Cookie object:
Cookie cookie = new Cookie("key","value");
(2) Setting the maximum age:
cookie.setMaxAge(60*60*24);
(3) Sending the Cookie into the HTTP response headers:
response.addCookie(cookie);
16. What is URL rewriting?(R)
In URL rewriting, a token(parameter) is added at the end of the URL. The token consist of
name/value pair seperated by an equal(=) sign.
17. What is JDBC? (U)
Java Database Connectivity(JDBC) is an Application Programming Interface(API)
used to connect Java application with Database. JDBC is used to interact with various type of
Database such as Oracle, MS Access, My SQL and SQL Server. JDBC can also be defined as
the platform-independent interface between a relational database and Java programming. It
allows java program to execute SQL statement and retrieve result from database.
33
18. What is the use of JDBC? (U)
Before JDBC, ODBC API was the database API to connect and execute query with the
database. But, ODBC API uses ODBC driver which is written in C language (i.e. platform
dependent and unsecured). That is why Java has defined its own API (JDBC API) that uses
JDBC drivers (written in Java language).
19. Define JDBC Driver and List its type.(R)
JDBC Driver is a software component that enables java application to interact with the
database. JDBC Driver is required to process SQL requests and generate result. The following
are the different types of driver available in JDBC.
∙ Type-1 Driver or JDBC-ODBC bridge
∙ Type-2 Driver or Native API Partly Java Driver
∙ Type-3 Driver or Network Protocol Driver (fully Java Driver)
∙ Type-4 Driver or Thin Driver (fully Java Driver)
20. List out the steps to connect a Java application with DB.(R)
There are 5 steps to connect any java application with the database in java using JDBC.
They are as follows:
1. Register the driver class
2. Creating connection
3. Creating statement
4. Executing queries
5. Closing connection
21. What is JSP? (U) (MAY/JUNE 2013) Java Server Pages (JSP) is a technology for developing
web pages that support dynamic content which helps developers insert java code in HTML
pages by making use of special JSP tags.
22. List some advantages of JSP. (AN
provides the separation between
presentation logic and business
logic.
6. JSP provides optional mechanism in
configuring web application file
(web.xml). 7. JSP allows creating and
using our own custom tag libraries.
Hence any application specific
Requirements can be satisfied using
custom tag libraries. This helps the
S.No
developer to develop any kind of
application.
8. Fast Development: No need to 1.
recompile and redeploy If JSP page
is modified, we don't need to
recompile and redeploy the project.
23. Differentiate JSP and Servlet. 4. (AN)
1. Extension to Servlet: JSP technology 2. Dynamic contents can be handled JSP is a webpage scripting language that
is the extension to servlet technology. can generate dynamic content.
We can use all the features of servlet in
JSP JSP
using JSP because JSP allows
scripting and element based
programming.
3. JSP is useful for server side programming. 4. JSP
programming is easy to learn and easy to implement.
5. JSP programming environment
2. In MVC, JSP act as a view.
3. It‟s easier to code in JSP than in Java Servlets.
5. JSP are generally preferred when there is involved. JSP.
not much processing of data required.
6. JSP run slower compared to Servlet as it
takes compilation time to convert into Java
Servlets.
7.
The advantage of JSP programming over servlets
is that we can build custom tags which can servlets.
directly call Java beans.
8.
JSP is almost a replacement of Servlets, (by V- SEM
large, the better word is extension of Servlets),
where coding decreases more than half
more processing and manipulation
In JSP, static code and dynamic code are
separated. Example:
Hello Mr. // static content
Servlets run faster compared to
<%= str %> // dynamic content as JSP
code you are great man // static content
There is no such custom tag facility in
35
Servlets are difficult to code
9. In JSP, both presentation Both presentation layer and
layer and business logic business logic layer put together
layer can be separated with in Servlets
the usage of JavaBeans.
Writing alias name
in <url-pattern> tag
of web.xml is Writing alias name in <url-
10. optional in JSP. pattern> tag of web.xml is
mandatory in Servlets
JSP needs no compilation
by the Programmer.
Programmer deploys In Servlets, the Programmer
11 directly a JSP source code compiles manually a Servlet file
. file in server. and deploys a .class file in server.
24. State the information in a JSP Documents. (R)
JSP page is a simple web page which contains
the three types of information: 1. JSP Markup
2. JSP Expression Language expressions
3 Template data
25. What is a Scriptlet? (U)
A scriptlet is a fragment of Java code that is embedded
within the JSP document. A scriptlet can contain any
number of JAVA language statements, variable or method
declarations, or expressions that are valid in the page
scripting language.
Syntax:
<% java source
code %>
26. What is meant by JSTL? (U)
The Java Server Pages Standard Tag Library (JSTL) is a
collection of useful JSP tags which encapsulates core
functionality common to many JSP applications.
27. List out the various JSTL tags.(R)
o Core Tags
o Formatting tags
o SQL tags
o XML tags
o JSTL Functions
28. Write appropriate javascript code to remove an
element(current element) from a DOM. (C)
(MAY/JUNE 2016)
Navigate to the node to be removed then use
parentNode property and removeChild ()
36
<html>
<head><script src="loadxmldoc.js"> </script></head>
<body><script>
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];
x.parentNode.removeChild(x);
</script></body>
</html>
29. Write the code segment to store current server time
in session using java servlet API. (C) MAY/JUNE
2016)
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
PrintWriter pw = resp.getWriter();
HttpSession session = req.getSession(true);
session.invalidate();
boolean result;
try {
session.getCreationTime();
result = false;
} catch (IllegalStateException ise) {
result = true;
}
if (result) {
pw.print("PASS");
} else {
pw.print("FAIL");
}
}
Method Description
Date()
Returns today's date and time
getDate()
Returns the day of the month for the specified date according to
32. List any four methods of Date object. (R)
(NOV/DEC 2016) The Date object is a datatype built
into the JavaScript language.
getDay() local time.
Returns the day of the week for the specified date
getFullYear()
according to local time.
Returns the year of the specified date according to local time.
37
33. Explain the servlet interface and its methods. (U) (NOV/DEC
2016) Servlet interface provides common behaviour to all the
servlets.Servlet interface needs to be implemented for creating any
servlet (either directly or indirectly). It provides 3 life cycle methods
that are used to initialize the servlet, to service the requests, and to
destroy the servlet and 2 non-life cycle methods.
Methods of Servlet interface
There are 5 methods in Servlet interface. The init, service and
destroy are the life cycle methods of servlet. These are invoked by
the web container.
Method Description
initializes the servlet. It is the life cycle
public void init(ServletConfig config) method of servlet and invoked by the web
container only once.
public void provides response for the incoming request.
service(ServletRequest It is invoked at each request by the web
request,ServletResponse container. is invoked only once and
response) indicates that servlet is being destroyed.
returns the object of ServletConfig.
public void destroy()
returns information about servlet such
public ServletConfig as writer, copyright, version etc.
getServletConfig() public
String getServletInfo()
34 .Explain validation in java script with suitable example ?
Code:-
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Validation</h2>
<p>Enter a number and click OK:</p>
<input id="id1" type="number" min="100" max="300" required>
<button onclick="myFunction()">OK</button>
<p>If the number is less than 100 or greater than 300, an error message will be
displayed.</p>
<p id="demo"></p>
<script>
function myFunction() {
const inpObj = document.getElementById("id1");
if (!inpObj.checkValidity()) {
document.getElementById("demo").innerHTML = inpObj.validationMessage;
} else {
document.getElementById("demo").innerHTML = "Input OK";
}
}
</script>
</body>
</html>
Life Cycle of a Servlet
The entire life cycle of a Servlet is managed by the Servlet container, which uses the
jakarta.servlet.Servlet interface to understand the Servlet object and manage it. So, before
creating a Servlet object, let's first understand the life cycle of the Servlet object, which is
actually understanding how the Servlet container manages the Servlet object.
Note: If you have worked with a servlet before, you must have used import javax.servlet.*; but
with Jakarta EE 9, the package names changed to import jakarta.servlet.*;
States of the Servlet Life Cycle
Diagram
The Servlet life cycle mainly goes through four stages, which is explained below:
. Loading a Servlet
The first stage of the Servlet lifecycle involves loading and initializing the Servlet. The Servlet
container performs the following operations:
Loading: The Servlet container loads the Servlet class into memory.
Instantiation: The container creates an instance of the Servlet using the no-argument
constructor.
The Servlet container can load the Servlet at one of the following times:
During the initialization of the web application (if the Servlet is configured with a zero or
positive integer value in the deployment descriptor).
When the Servlet is first requested by a client (if lazy loading is enabled).
2. Initializing a Servlet
After the Servlet is instantiated, the Servlet container initializes it by calling the
init(ServletConfig config) method. This method is called only once during the Servlet's life
cycle.
3. Handling request
Once the Servlet is initialized, it is ready to handle client requests. The Servlet container
performs the following steps for each request:
Create Request and Response Objects
o The container creates ServletRequest and ServletResponse objects.
o For HTTP requests, it
creates HttpServletRequest and HttpServletResponse objects.
Invoke the service() Method
o The container calls the service(ServletRequest req, ServletResponse res)
method.
o The service() method determines the type of HTTP request (GET, POST, PUT,
DELETE, etc.) and delegates the request to the appropriate method (doGet(),
doPost(), etc).
4. Destroying a Servlet
When the Servlet container decides to remove the Servlet, it follows these steps which are listed
below
Allow Active Threads to Complete: The container ensures that all threads executing
the service() method complete their tasks.
Invoke the destroy() Method: The container calls the destroy() method to allow the
Servlet to release resources (e.g., closing database connections, freeing memory).
Release Servlet Instance: After the destroy() method is executed, the Servlet container
releases all references to the Servlet instance, making it eligible for garbage collection
Servlet Life Cycle Methods
There are three life cycle methods of a Servlet:
init()
service()
destroy()
Explain SERVEr Architecture:-
What are Servlets?
Java Servlets are programs that run on a Web or Application server and act as a middle layer
between a requests coming from a Web browser or other HTTP client and databases or
applications on the HTTP server.
Using Servlets, you can collect input from users through web page forms, present records from a
database or another source, and create web pages dynamically.
Java Servlets often serve the same purpose as programs implemented using the Common
Gateway Interface (CGI). But Servlets offer several advantages in comparison with the CGI.
Performance is significantly better.
Servlets execute within the address space of a Web server. It is not necessary to create a
separate process to handle each client request.
Servlets are platform-independent because they are written in Java.
Java security manager on the server enforces a set of restrictions to protect the resources
on a server machine. So servlets are trusted.
The full functionality of the Java class libraries is available to a servlet. It can
communicate with applets, databases, or other software via the sockets and RMI
mechanisms that you have seen already.
Servlets Architecture
The following diagram shows the position of Servlets in a Web Application.
Servlets Tasks
Servlets perform the following major tasks −
Read the explicit data sent by the clients (browsers). This includes an HTML form on a
Web page or it could also come from an applet or a custom HTTP client program.
Read the implicit HTTP request data sent by the clients (browsers). This includes
cookies, media types and compression schemes the browser understands, and so forth.
Process the data and generate the results. This process may require talking to a database,
executing an RMI or CORBA call, invoking a Web service, or computing the response
directly.
Send the explicit data (i.e., the document) to the clients (browsers). This document can be
sent in a variety of formats, including text (HTML or XML), binary (GIF images), Excel,
etc.
Send the implicit HTTP response to the clients (browsers). This includes telling the
browsers or other clients what type of document is being returned (e.g., HTML), setting
cookies and caching parameters, and other such tasks.
Servlets Packages
Java Servlets are Java classes run by a web server that has an interpreter that supports the Java
Servlet specification.
Servlets can be created using the javax.servlet and javax.servlet.http packages, which are a
standard part of the Java's enterprise edition, an expanded version of the Java class library that
supports large-scale development projects.
These classes implement the Java Servlet and JSP specifications. At the time of writing this
tutorial, the versions are Java Servlet 2.5 and JSP 2.1.
Java servlets have been created and compiled just like any other Java class. After you install the
servlet packages and add them to your computer's Classpath, you can compile servlets with the
JDK's Java compiler or any other current compiler.
Differences Between RMI and Socket (information)
RMI Socket
Remote Method Invocation is basically an
Sockets are nothing but two-sided communication
API which allows an object to invoke a
links between two programs (client and server) in
method on an object running in a different
a network.
machine's JVM.
RMI is remote method invocation which
Sockets are like gateways which provide access
means methods are invoked remotely or
points for programs through some specific port
accessing remote sites in client-server
numbers.
communication.
In this, we have to manage which sockets and
RMI is built on top of sockets. Without protocols the application will use. Even though we
sockets, RMI wouldn't exist. can format messages travelling between client
and server-side.
RMI is object-oriented Whereas it is not.
Here we specify TCP or UDP type, we have to
RMI handles the formatting of messages
handle all the formatting of messages travelling
between client and server.
between client and server.
Socket-based Communication is independent of
RMI is a Java-specific technology.
programming languages.
RMI is for high-level java to java distributed
Sockets are for low-level network communication.
computing.