Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution Q1) Explain get(), post(), head(),put(), and delete() method to handle the HTTP actions? [5] Ans: GET The GET method requests a representation of the specified resource. Requests using GET should only retrieve data. HEAD The HEAD method asks for a response identical to that of a GET request, but without the response body. POST The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server. PUT The PUT method replaces all current representations of the target resource with the request payload. DELETE The DELETE method deletes the specified resource. Q1 b) Write an HTML Page and also provide a JavaScript for accepting 2 numbers from user and will perform basic arithmetic operations..[5] Ans: <html> <head> <title>JavaScript Demo</title> <script type="text/javascript"> function calcSum() { value1 = parseInt(document.mainForm.textBox1.value); value2 = parseInt(document.mainForm.textBox2.value); sum = value1 + value2; sub= value1-value2; mul=value1*value2; div=value1/value2; document.mainForm.tsum.value = sum; document.mainForm.tsub.value = sub; document.mainForm.tmul.value = mul; document.mainForm.tdiv.value = div; } </script> </head> <body>
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution Q1) Explain get(), post(), head(),put(), and delete() method to handle the HTTP actions? [5]
Ans:
GET
The GET method requests a representation of the specified resource. Requests using GET
should only retrieve data.
HEAD
The HEAD method asks for a response identical to that of a GET request, but without the
response body.
POST
The POST method is used to submit an entity to the specified resource, often causing a
change in state or side effects on the server.
PUT
The PUT method replaces all current representations of the target resource with the
request payload.
DELETE
The DELETE method deletes the specified resource.
Q1 b) Write an HTML Page and also provide a JavaScript for accepting 2 numbers from user
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution
Q3a) Write a JSP Scriplet for displaying even numbers between 1 to 50.[5]
Ans:
<html>
<body>
<%
out.println("Printing Even numbers between 1 and 50 ");
for(int i=1; i <= 50; i++)
{
if( i % 2 == 0){
out.print(i + "<br> ");
}
}
%>
</body>
</html>
Q3b) List and discuss the different design issues in web development?.[5]
Ans:
Browser Compatibility:- The web page should be properly displayed on different browsers like
chrome, Firefox , IE and mobile compatible browser like safari and opera Mini. Hence while
building website, the web pages should be checked on all possible browsers and os, with old and
latest versions.
Screen Resolution:- Usually common resolution of screen is 1024*768 pixels, but now there is
growing trend towards higher resolution. If the website is designed for higher resolution, it may be
possible that some low resolution screens may not be able to display contents.
Internet Speed:- Near about 50% of web users expect that the web page should be loaded in 2 sec
oe even less. Use of more images or heavy media like animations or video slow down the
downloading process of web pages.
Scalability:- Scalability is another issue which a developer need to keeps in mind while developing.
Scalability is the process of balancing the loads between the servers. scalability factor comes into
play when the traffic of a page of website suddenly increases. so the developer should design the
website in a way that additional servers can be added if needed.
Security:- Security is a factor which cannot be neglected at any cost because data breach can be
very harmful for any online business or any personal website. Developers need to consider about
many things when it comes to security like denial of service attacks, safety of users data like name
and contact information, database malfunctioning. unauthorized access, and other security threats
like phishing, ,shell injection and cross site scripting.
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution Q4a) Create a servlet in Java to get user ID and Password parameters which are entered in
Q5c) Find out and explain how XML and AJAX are related.[4M]
Ans:
AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better,
faster, and more interactive web applications with the help of XML, HTML, CSS, and Java Script.
Ajax uses XHTML for content, CSS for presentation, along with Document Object Model and
JavaScript for dynamic content display.
Conventional web applications transmit information to and from the sever using
synchronous requests. It means you fill out a form, hit submit, and get directed to a new
page with new information from the server.
With AJAX, when you hit submit, JavaScript will make a request to the server, interpret the
results, and update the current screen. In the purest sense, the user would never know that
anything was even transmitted to the server.
XML is commonly used as the format for receiving server data, although any format,
including plain text, can be used.
Q6a) Briefly explain the basic structure of PHP program with an example.[6]
Ans:
PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites
or Web applications. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home
Pages. PHP scripts can only be interpreted on a server that has PHP installed.
PHP is an embedded scripting language when used in web pages. This means that PHP code is
embedded in HTML code. You use HTML tags to enclose the PHP language that you embed in your
HTML file — the same way that you would use other HTML tags. You create and edit web pages
containing PHP the same way that you create and edit regular HTML pages.
The PHP language statements are enclosed in PHP tags with the following form:
<?php ?>
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution The following listing shows a PHP script that does the same thing — it displays Hello World! in a
browser window.
<!doctype html>
<html>
<head><title>Hello World Script</title></head>
<body>
<?php
echo "<p>Hello World!</p>n";
?>
</body>
</html>
Any files that live on your web server must have the .php extension in order to use PHP within the
page.
Q6b) Write PHP script to display the squares and Cubes of 1 to 10 numbers.[6]
Ans:
<?php
$n=1;
while(n<=10)
{
$square=$n*$n;
$cube=$n*$n*$n;
Echo “The Square of $n is @square and Cube is $cube”;
$n++;
}
?>
Q6c) Classify Data types of PHP and describe various data types in each type[4]
Ans: PHP supports the following data types:
Primitive
String
Integer
Float (floating point numbers - also called double)
Boolean
Non-Primitive
Array
Object
NULL
Resource
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution PHP String
A string is a sequence of characters, like "Hello world!".A string can be any text inside quotes. You
can use single or double quotes:
Example
<?php
$x = "Hello world!";
echo $x; ?>
PHP Integer
An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647. In the
following example $x is an integer. The PHP var_dump() function returns the data type and value:
Example
<?php
$x = 5985;
var_dump($x);
?>
PHP Float
A float (floating point number) is a number with a decimal point or a number in exponential form.
In the following example $x is a float. The PHP var_dump() function returns the data type and value:
Example
<?php
$x = 10.365;
var_dump($x);
?>
PHP Boolean
A Boolean represents two possible states: TRUE or FALSE. Booleans are often used in conditional
testing.
$x = true;
$y = false;
PHP Array
An array stores multiple values in one single variable. In the following example $cars is an array.
The PHP var_dump() function returns the data type and value:
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution Example
<?php
$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
?>
PHP Object
An object is a data type which stores data and information on how to process that data. In PHP, an
object must be explicitly declared. First we must declare a class of object. For this, we use the class
keyword. A class is a structure that can contain properties and methods:
Example
<?php
class Car {
function Car() {
$this->model = "VW";
}
}
// create an object
$herbie = new Car();
// show object properties
echo $herbie->model;
?>
PHP NULL Value
Null is a special data type which can have only one value: NULL. A variable of data type NULL is a
variable that has no value assigned to it. Variables can also be emptied by setting the value to NULL:
Example
<?php
$x = null;
var_dump($x);
?>
PHP Resource
The special resource type is not an actual data type. It is the storing of a reference to functions and
resources external to PHP.A common example of using the resource data type is a database call.
Q7a) Create simple AngularJS application to display "Hello, Input Name" using proper
directive.[6]
Ans:
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution <html><head>
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution
Directive Description
ng-init Initializes AngularJS variables
ng-model Binds HTML control's value to a property on the $scope object.
ng-
controller Attaches the controller of MVC to the view.
ng-bind Replaces the value of HTML control with the value of specified AngularJS expression.
ng-repeat Repeats HTML template once per each item in the specified collection.
ng-show Display HTML element based on the value of the specified expression.
ng-readonly Makes HTML element read-only based on the value of the specified expression.
ng-disabled Sets the disable attribute on the HTML element if specified expression evaluates to
true.
ng-if Removes or recreates HTML element based on an expression.
ng-click Specifies custom behavior when an element is clicked.
Q8a) Does AngularJS support Single Page Application via multiple views on a single page?
Justify your answer. [6M]
Ans:
Yes, AngularJS support Single Page Application via multiple views on a single page.
To do this, AngularJS has provided ng-view and ng-template directives, and $routeProvider
services.
ng-view Directive
The ng-view directive simply creates a place holder where a corresponding view (HTML or ng-
template view) can be placed based on the configuration.
Usage
Define a div with ng-view within the main module.
<div ng-app = "mainApp">
<div ng-view></div>
</div>
ng-template Directive
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution The ng-template directive is used to create an HTML view using script tag. It contains id attribute
which is used by $routeProvider to map a view with a controller.
Usage
Define a script block with type as ng-template within the main module.
<div ng-app = "mainApp">
<script type = "text/ng-template" id = "addStudent.htm">
<h2> Add Student </h2>
{{message}}
</script>
</div>
$routeProvider Service
The $routeProvider is a key service which sets the configuration of URLs, maps them with the
corresponding HTML page or ng-template, and attaches a controller with the same.
Usage 1
Define a script block with type as ng-template within the main module.
<div ng-app = "mainApp">
...
<script type = "text/ng-template" id = "addStudent.htm">
<h2> Add Student </h2>
{{message}}
</script>
</div>
Usage 2
Define a script block with main module and set the routing configuration.
var mainApp = angular.module("mainApp", ['ngRoute']);
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution
Stateless: These beans do not declare any instance (class-level) variables, so that the
methods contained within can act only on any local parameters. There is no way to maintain
state across method calls.
Stateful: These beans can hold client state across method invocations. This is possible with
the use of instance variables declared in the class definition. The client will then set the
values for these variables and use these values in other method calls.
There may be more work involved for the server to share stateful session beans than is required to
share stateless beans. Storing the state of an EJB is a very resource-intensive process, so an
application that uses stateful beans may not be easily scalable. Stateless session beans provide
excellent scalability, because the EJB container does not need to keep track of their state across
method calls.
Q9c) Write short note on bootstrap [4]
Ans:
Bootstrap History
• Bootstrap was developed by Mark Otto and Jacob Thornton at Twitter, and released
as an open source product in August 2011 on GitHub.
• In June 2014 Bootstrap was the No.1 project on GitHub!
Where to Get Bootstrap?
• Download Bootstrap from getbootstrap.com
• Include Bootstrap from a CDN
What You Can Do with Bootstrap
You can easily create responsive websites.
You can quickly create multi-column layout with pre-defined classes.
You can quickly create different types of form layouts.
You can quickly create different variation of navigation bar.
You can easily create components like accordions, modals, etc. without writing any JS code.
You can easily create dynamic tabs to manage large amount of content.
You can easily create tooltips and popovers to show hint text.
You can easily create carousel or image slider to showcase your content.
You can quickly create different types of alert boxes.
The list does not end here, there are many other interesting things that you can do with Bootstrap.
You will learn about all of them in detail in upcoming chapters.
Advantages of Using Bootstrap
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution If you have had some experience with any front-end framework, you might be wondering what
makes Bootstrap so special. Here are some advantages why one should opt for Bootstrap
framework:
Save lots of time — You can save lots of time and efforts using the Bootstrap predefined
design templates and classes and concentrate on other development work.
Responsive features — Using Bootstrap you can easily create responsive websites that
appear more appropriately on different devices and screen resolutions without any change
in markup.
Consistent design — All Bootstrap components share the same design templates and styles
through a central library, so the design and layout of your web pages will be consistent.
Easy to use — Bootstrap is very easy to use. Anybody with the basic working knowledge of
HTML, CSS and JavaScript can start development with Bootstrap.
Compatible with browsers — Bootstrap is created with modern web browsers in mind
and it is compatible with all modern browsers such as Chrome, Firefox, Safari, Internet
Explorer, etc.
Open Source — And the best part is, it is completely free to download and use.
Q10a) What is EJB? Draw & explain main components of EJB Architecture. [8]
Ans:
• EJB stands for Enterprise Java Beans.
• EJB is an essential part of a J2EE platform.
• EJB provides an architecture to develop and deploy component based enterprise
applications considering robustness, high scalability, and high performance.
• When use Enterprise Java Bean?
• Application needs Remote Access. In other words, it is distributed.
• Application needs to be scalable. EJB applications supports load balancing,
clustering and fail-over.
• Application needs encapsulated business logic. EJB application is separated from
presentation and persistent layer.
EJB Architecture
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution
Fig: EJB Architecture
EJB Architecture- Components
• EJB Server:
• Outmost container
• Manage EJB Container
• Provides runtime environment
• Services
1. Process & thread management
2. System recourse management
3. Database connection pooling & catching
EJB client An EJB client usually provides the user-interface logic on a client machine. The EJB client
makes calls to remote EJB components on a server and needs to know how to find the EJB server
and how to interact with the EJB components. An EJB component can act as an EJB client by calling
methods in another EJB component.
An EJB client does not communicate directly with an EJB component. The container provides proxy
objects that implement the components home and remote interfaces. The component’s remote
interface defines the business methods that can be called by the client. The client calls the home
interface methods to create and destroy proxies for the remote interface.
EJB container The EJB specification defines a container as the environment in which one or more
EJB components execute. The container provides the infrastructure required to run distributed
components, allowing client and component developers to focus on programming business logic,
and not system-level code. In EAServer, the container encapsulates:
The client runtime and generated stub classes, which allow clients to execute components
on a remote server as if they were local objects.
The naming service, which allows clients to instantiate components by name, and
components to obtain resources such as database connections by name.
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution
The EAServer component dispatcher, which executes the component’s implementation class
and provides services such as transaction management, database connection pooling, and
instance lifecycle management.
EJB component implementation The Java class that runs in the server implements the bean’s
business logic. The class must implement the remote interface methods and additional methods for
lifecycle management.
Q9b) What are the web services? List & discuss components of Web Services.[6]
Ans:
• A Web Service is can be defined by following ways:
• is a client server application or application component for communication.
• method of communication between two devices over network.
• is a collection of standards or protocols for exchanging information between two
devices or application.
• Is available over the Internet or private (intranet) networks
• Uses a standardized XML messaging system
• Is not tied to any one operating system or programming language
• Is self-describing via a common XML grammar
• Is discoverable via a simple find mechanism
Components of Web Services
• The basic web services platform is XML + HTTP. All the standard web services work using
the following components −
• SOAP (Simple Object Access Protocol)
• UDDI (Universal Description, Discovery and Integration)
• WSDL (Web Services Description Language)
• SOAP
• SOAP is an XML-based protocol for exchanging information between computers.
• SOAP is a communication protocol.
• SOAP is for communication between applications.
• SOAP is a format for sending messages.
• SOAP is designed to communicate via Internet.
• SOAP is platform independent.
• SOAP is language independent.
• SOAP is simple and extensible.
• SOAP allows you to get around firewalls.
• SOAP will be developed as a W3C standard.
• WSDL
• WSDL is an XML-based language for describing web services and how to access
them.
• WSDL stands for Web Services Description Language.
• WSDL was developed jointly by Microsoft and IBM.
• WSDL is an XML based protocol for information exchange in decentralized and
distributed environments.
• WSDL is the standard format for describing a web service.
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution
• WSDL definition describes how to access a web service and what operations it will
perform.
• WSDL is a language for describing how to interface with XML-based services.
• WSDL is an integral part of UDDI, an XML-based worldwide business registry.
• WSDL is the language that UDDI uses.
• WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'.
• UDDI
• UDDI is an XML-based standard for describing, publishing, and finding web services.
• UDDI stands for Universal Description, Discovery, and Integration.
• UDDI is a specification for a distributed registry of web services.
• UDDI is platform independent, open framework.
• UDDI can communicate via SOAP, CORBA, and Java RMI Protocol.
• UDDI uses WSDL to describe interfaces to web services.
• UDDI is seen with SOAP and WSDL as one of the three foundation standards of web
services.
• UDDI is an open industry initiative enabling businesses to discover each other and
define how they interact over the Internet.
Q10c) Write short note on Content Management System. [4]
Ans
• A content management system (CMS) is a computer application that supports the creation
and modification of digital content.
• It typically supports multiple users in a collaborative environment.
• CMS features vary widely. Most CMSs include Web-based publishing, format management,
history editing and version control, indexing, search, and retrieval.
• CMS is designed to support the management of the content of Web pages. Web content
includes text and embedded graphics, photos, video, audio, maps, and program code (e.g.,
for applications) that displays content or interacts with the user.
• Such a content management system (CMS) typically has two major components:
• A content management application (CMA) is the front-end user interface that allows
a user, to add, modify, and remove content from a website.
• A content delivery application (CDA) compiles that information and updates the
website.
• Examples of CMS
• WordPress,
• Joomla
• Drupal.
• Advantages
• Reduced need to code from scratch
• Easy to create a unified look and feel
Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution
• Version control
• Edit permission management
• Disadvantages
• Limited or no ability to create functionality not proposed in the CMS (e.g., layouts,
web apps, etc.)
• Increased need for special expertise and training for content authors