0% found this document useful (0 votes)
32 views

IP - Models - Answer Key

This document contains an answer key for a Computer Science exam on Internet Programming. It provides answers to 10 short answer questions covering topics like protocols, CSS, regular expressions, JSON, servlets, PHP functions, HTTP requests, and AJAX merits. It also contains answers to 5 longer questions about CSS versions, website asset optimization techniques, using JSON in JavaScript, and benefits of JSON over XML.

Uploaded by

Suresh Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

IP - Models - Answer Key

This document contains an answer key for a Computer Science exam on Internet Programming. It provides answers to 10 short answer questions covering topics like protocols, CSS, regular expressions, JSON, servlets, PHP functions, HTTP requests, and AJAX merits. It also contains answers to 5 longer questions about CSS versions, website asset optimization techniques, using JSON in JavaScript, and benefits of JSON over XML.

Uploaded by

Suresh Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

KGiSL Institute of Technology

(Affiliated to ANNA University, Chennai and Approved by AICTE, New Delhi)


365, KGiSL Campus, Thudiyalur Road, Saravanampatti, Coimbatore – 641035

Department of Computer Science & Engineering

Model Exam : Answer Key


BRANCH: CSE
YEAR/ SEM / SEC: III / VI / A /B
COURSE CODE: CS8651
COURSE NAME: INTERNET PROGRAMMING
PART – A (10 X 2 = 20 Marks)
ANSWER ALL QUESTIONS

1. Define Protocol and list various types of protocols.


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
2. Mention the need for Cascading Style Sheets.
 CSS allows the separation between the information contained in a document and its presentation.
 Any change in the presentation can be made without disturbing the information of the document.
 CSS allows developers to give the consistent appearance to all elements of the web page.
3. What is Regular Expression in Java Script? How do you define RE?
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]+$/;
4. What is JSON? Whether it is platform dependent?
A common use of JSON is to read data from a web server, and display the data in a web page.
 JSON stands for JavaScript Object Notation.
 JSON is lightweight data-interchange format.
 JSON is easy to read and write than XML.
 JSON is language independent.
 JSON supports array, object, string, number and values.
5. What are Servlets? List its life cycle methods.
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:
 Init() – It performs servlet initialization tasks. This method is called when the servlet is loaded in
the memory for the first time.
 Service() – is a method actually called when an HTTP request is received; this method, in turn,
calls doGet(). Normally, you should not override service().
 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.
6. What is meant by Session Tracking or Session Handling?
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.
7. What is PHP? Name some built-in functions in PHP.
 Array Functions
 Class/Object Functions
 Character Functions
 Date & Time Functions
 Error Handling Functions
 MySQL Functions
 ODBC Functions
 String Functions
 XML Parsing Functions
8. Why is XSLT an important tool in development of web applications?
XSLT is the most important part of XSL.XSLT is used to transform an XML document into another
XML document, or another type of document that is recognized by a browser, like HTML and XHTML.
Normally XSLT does this by transforming each XML element into an (X)HTML element. With XSLT you
can add/remove elements and attributes to or from the output file. You can also rearrange and sort elements,
perform tests and make decisions about which elements to hide and display, and a lot more.A common way
to describe the transformation process is to say that XSLT transforms an XML source-tree into an XML
result-tree.
9. Define HTTP Request Object.
The XMLHttpRequest Object is the layer between the client and the server that creates and manages
asynchronous requests in Ajax applications. All modern browsers support the XMLHttpRequest object (IE5
and IE6 use an ActiveXObject).
10. List any four merits for usage of AJAX in web service.
1. Reduce the traffic travels between the client and the server.
2. Response time is faster so increases performance and speed.
3. AJAX communicates over HTTP protocol.
4. Asynchronous calls to a web server allows client need not to wait for the arrival of all data before
start rendering.
5. If a section of a page encounters any error, other sections do not get affected and the data entered
by the user is also not lost.
PART – B (5 X 13= 65 Marks)
ANSWER ALL QUESTIONS
11.(a)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?
CSS modules are:
CSS files in which all class names and animation names are scoped locally by default. So CSS Modules
is not an official spec or an implementation in the browser but rather a process in a build step (with the
help of Webpack or Browserify) that changes class names and selectors to be scoped (i.e. kinda like
namespaced).

S.No. CSS CSS3


On the other hand, CSS3 is capable of making the
CSS is capable of positioning texts
1 web page more attractive and takes less time to
and objects.
create. CSS3 is backward compatible with CSS.
Responsive designing is not CSS3 is the latest version, hence it supports
2
supported in CSS responsive design.
3 CSS cannot be split into modules. Whereas CSS3 can be breakdown into modules.
But in CSS3 we can perform all kinds of animation
Using CSS, we cannot build 3D
4 and transformations as it supports animation and
animation and transformation.
3D transformations.
CSS is very slow as compared to
5 Whereas CSS3 is faster than CSS.
CSS3
In CSS we have set of standard
Whereas CSS3 has a good collection of HSL
6 colors and it uses basic color
RGBA, HSLA, and gradient colors.
schemes only.
In CSS we can only use single text
7 But in CSS3 we can use multi-column text blocks
blocks.
CSS does not support media
8 But CSS3 supports media queries
queries.
CSS codes are not supported by all Being the latest version, CSS3 codes are supported
9
types of modern browsers. by all modern browsers.
In CSS, the user can add
Whereas CSS3 list has a special display property
background colors to list items and
10 defined in it. Even list items also have counter
lists, set images for the list items,
reset properties.
etc.
CSS3 is the latest version of CSS and was released
11 CSS was developed in 1996.
in 2005.
CSS3 memory consumption is low as compared to
12 CSS is memory intensive.
CSS.

(OR)
(b) Demonstrate the techniques used to optimize website assets loading.
Tips To Improve Web Optimization
1. Prefetching should be enabled
2. Provide fast loading times
3. Scripts should be placed at the bottom and style sheets at the top
4. Asynchronous Scripts
5. Reduce HTTP requests by combining JavaScript and CSS files
6. Files should be compressed
7. Prioritize mobile-first Approach
8. Make use of web
9. Utilize a CDN service
10. Reduce HTTP requests
12. (a) Demonstrate use of JSON. How to convert JavaScript objects to JSON ? List the benefits of
JSON over XML
Uses of JSON:
 It is used while writing JavaScript based applications that includes browser extensions and websites.
 JSON format is used for serializing and transmitting structured data over network connection.
 It is primarily used to transmit data between a server and web applications.
 Web services and APIs use JSON format to provide public data.
 It can be used with modern programming languages.
 The JSON format is syntactically similar to the code for creating JavaScript objects. Because of this,
a JavaScript program can easily convert JSON data into JavaScript objects.Since the format is text
only, JSON data can easily be sent between computers, and used by any programming language.

Reasons to choose JSON over XML

1. JSON requires less tags than XML – XML items must be wrapped in open and close tags whereas
JSON you just name the tag once
2. Because JSON is transportation-independent, you can just bypass the XMLHttpRequest object for
getting your data.
3. JavaScript is not just data – you can also put methods and all sorts of goodies in JSON format.
4. JSON is better at helping procedural decisions in your JavaScript based on objects and their values
(or methods).
5. You can get JSON data from anywhere, not just your own domain. There’s no more proxy server
nonsense.
6. JSON is easier to read than XML

(OR)
(b) Whether JavaScript a statically types or dynamically typed language. Justify your answer with
examples.
A language with static types is referred to as a statically-typed language. On the other hand, a language
with dynamic types is referred to as a dynamically-typed language. The core difference is that statically-
typed languages perform type checking at compile time, while dynamically-typed languages perform type
checking at runtime. This leaves one more concept for you to tackle: what does “type-checking” mean?
To explain, let’s look at types in Java versus Javascript.

“Types” refers to the type of data being defined.


boolean result = true;
This has a correct type, because the boolean annotation matches the value given to result, as opposed to an
integer or anything else.
boolean result = 123;
…this would fail to compile because it has an incorrect type. It explicitly marks result as a boolean, but then
defines it as the integer 123.
JavaScript and other dynamically-typed languages have a different approach, allowing the context to establish
what type of data is being defined:

var result = true;

Long story short: statically-typed languages require you to declare the data types of your constructs before you
can use them. Dynamically-typed languages do not. JavaScript implies the data type, while Java states it
outright.So as you can see, types allow you to specify program invariants, or the logical assertions and
conditions under which the program will execute.
Type-checking verifies and enforces that the type of a construct (constant, boolean, number, variable,
array, object) matches an invariant that you’ve specified. You might, for example, specify that “this function
always returns a string.” When the program runs, you can safely assume that it will return a string.
The differences between static type checking and dynamic type checking matter most when a type error occurs.
In a statically-typed language, type errors occur during the compilation step, that is, at compile time. In
dynamically-typed languages, the errors occur only once the program is executed. That is, at runtime.
This means that a program written in a dynamically-typed language (like JavaScript or Python) can compile
even if it contains type errors that would otherwise prevent the script from running properly.

13 (a) Demonstrate the Single-Threaded Model in Servlets. How does Servlets Collaboration take
place?
Single Thread Model Interface was designed to guarantee that only one thread is executed at a
time in a given servlet instance service method. It should be implemented to ensure that the servlet can
handle only one request at a time. It is a marker interface and has no methods. Once the interface is
implemented the system guarantees that there’s never more than one request thread accessing a single
instance servlet. This interface is currently deprecated because this doesn’t solve all the thread safety
issues such as static variable and session attributes can be accessed by multiple threads at the same
time even if we implemented the SingleThreadModel interface. That’s why to resolve the thread-
safety issues it is recommended to use a synchronized block .
Syntax:
public class Myservlet extends Httpservlet implements SingleThreadModel {
}
Implementation: SingleThreadModel interface
We created three files to make this application:
1. index.html
2. Myservlet.java
3. web.xml
The index.html file creates a link to invoke the servlet of URL-pattern “servlet1” and Myservlet class extends
HttpServlet and implements the SingleThreadModel interface. Class Myservlet is a servlet that handles Single
requests at a single time and sleep() is a static method in the Thread class used to suspend the execution of a
thread for two thousand milliseconds. When another user will try to access the same servlet, the new instance
is created instead of using the same instance for multiple threads.
(OR)
(b) Illustrate about the following with an example.
a. JSP and Servlet
Servlet technology is used to create a web application. A servlet is a Java class that is used to
extend the capabilities of servers that host applications accessed by means of a request-response
model. Servlets are mainly used to extend the applications hosted by web services.
JSP is used to create web applications just like Servlet technology. A JSP is a text document that
contains two types of text: static data and dynamic data. The static data can be expressed in any
text-based format (like HTML, XML, SVG, and WML), and the dynamic content can be
expressed by JSP elements

b. Running JSP Application.

 Apache Tomcat Server(Jakarta Tomcat): It is an open source web server and servlet container
developed by the Apache Software Foundation (ASF). It implements the Java Servlet and the JavaServer
Pages (JSP) specifications and provides a pure Java HTTP web server environment for java code to run.
 JavaServerPages(JSP): It is a technology that helps in creating dynamically generated web pages.
Step1
Install Java.

Step2
InstallApacheTomcat
At the time of installation, it will by-default recognize JRE path.(under installed java location directory)

Step3
Now Go-To:

 Start
 Programs
 APACHE TOMCAT
 MONITOR TOMCAT

Step4
An icon will appear on the taskbar, this icon will automatically appear after following above step:

Step5
Click on that icon and START TOMCAT, you can see the following dialog box:

Step6
Now open Mozilla Firefox(or any other browser)

Step7
Type http://localhost:8080/ on address bar and press enter.

The same can be seen here:


Step8
It will show tomcat, as shown in above window.

(if not, then try again, may be a problem in installation or you’re not following above steps correctly

Step9
Now, go to:

 C:drive
 Programs Files
 Apache Software Foundation
 tomcat
 web-apps

Step10
Open web-apps and “copy your project” or “make new folder”, which you want to run in JSP.
Example: amit2012PROJECT

 Tomcat
 Root
 Copy Web-inf from root
 Paste this “web-inf” in your project folder i.e. amit2012PROJECT

Step11
Create a text file and name it as first.jsp,

14. (a) Demonstrate the features of built-in functions in PHP with examples

There are two types of functions as:

1. Internal (built-in) Functions


2. User Defined Functions
PHP comes standard with many functions and constructs. i.e.
phpinfo() print() mysqli_connect() error_reporting()
error_log() array() copy() unlink()
date() time() strlen() strlen()
Some (not even most) usage of built-in functions are as mentioned below:
 Converting a string of letters to uppercase and lowercase
 Displaying and using the date and time
 Initializing and closing a database connection
 Declaring and using an array
 Handling files
 Accessing data in forms
 Filesystem Functions
 Function to open FTP connections
 Email related functions
 Mathematical Functions
 MySQL specific functions
 URL Functions
 Image functions

Using Your own PHP Function (User Defined Functions)

 You can also create your own functions.


 First, you need to give it a name.
 All functions in PHP start with function().
 Functions can also accept parameters.
 A function can also be used to return values.

(OR)
(b) Explain about DOM with the XML data processing.

The DOM defines a standard for accessing and manipulating documents:

"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs
and scripts to dynamically access and update the content, structure, and style of a document."

The HTML DOM defines a standard way for accessing and manipulating HTML documents. It presents an
HTML document as a tree-structure.The XML DOM defines a standard way for accessing and manipulating
XML documents. It presents an XML document as a tree-structure.Understanding the DOM is a must for
anyone working with HTML or XML.

All HTML elements can be accessed through the HTML DOM.

This example changes the value of an HTML element with id="demo":

Example
<h1 id="demo">This is a Heading</h1>

<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>

This example changes the value of the first <h1> element in an HTML document:

Example
<h1>This is a Heading</h1>
<h1>This is a Heading</h1>

<script>
document.getElementsByTagName("h1")[0].innerHTML = "Hello World!";
</script>
15. (a) Demonstrate about the structure of a WSDL document , its elements and their purposes with
appropriate examples
The WSDL Document Structure
The main structure of a WSDL document looks like this −

<definitions>
<types>
definition of types........
</types>
<message>
definition of a message....
</message>
<portType>
<operation>
definition of a operation.......
</operation>
</portType>
<binding>
definition of a binding....
</binding>
<service>
definition of a service....
</service>
</definitions>
(OR)
(b) Demonstrate about the AJAX client-server architecture with neat diagram

PART – C (1X 15 = 15 Marks)

ANSWER ALL QUESTIONS


16. (a) Explain the JDBC and its components
Java Database Connectivity (JDBC) is an Application Programming Interface (API), from Sun microsystem
that is used by the Java application to communicate with the relational databases from different vendors. JDBC
and database drivers work in tandem to access spreadsheets and databases. Design of JDBC defines the
components of JDBC, which is used for connecting to the database.

Components of JDBC

JDBC has four major components that are used for the interaction with the database.

1. JDBC API
2. JDBC Test Suite
3. JDBC Driver Manger
4. JDBC ODBC Bridge Driver

(OR)

(b) Explain the SOAP elements in detail

It is important for web applications to be able to communicate over the Internet.The best way to communicate
between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was
created to accomplish this.SOAP provides a way to communicate between applications running on different
operating systems, with different technologies and programming languages.

SOAP Building Blocks

A SOAP message is an ordinary XML document containing the following elements:

 An Envelope element that identifies the XML document as a SOAP message


 A Header element that contains header information
 A Body element that contains call and response information
 A Fault element containing errors and status information

Syntax Rules

Here are some important syntax rules:

 A SOAP message MUST be encoded using XML


 A SOAP message MUST use the SOAP Envelope namespace
 A SOAP message must NOT contain a DTD reference
 A SOAP message must NOT contain XML Processing Instructions

Skeleton SOAP Message


<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Header>...
</soap:Header>
<soap:Body>...
<soap:Fault> ...
</soap:Fault>
</soap:Body>
</soap:Envelope>

The SOAP Envelope Element

The required SOAP Envelope element is the root element of a SOAP message. This element defines the XML
document as a SOAP message.

Faculty In-Charge HoD

You might also like