Top Banner
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>
27

MOCK-ENDSEM Paper Solution - WordPress.com

Mar 22, 2023

Download

Documents

Khang Minh
Welcome message from author
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
Page 1: MOCK-ENDSEM Paper Solution - WordPress.com

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>

Page 2: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution <form name="mainForm">

<input type="text" name="textBox1" /> <br/>

<input type="text" name="textBox2" /> <br/>

<input type="button" value="Process" onclick="javascript: calcSum()" />

<input type="text" name="tsum" readonly="readonly"/>

<input type="text" name="tsub" readonly="readonly"/>

<input type="text" name="tmul" readonly="readonly"/>

<input type="text" name="tdiv" readonly="readonly"/>

</form>

</body>

</html>

Q2a) What are the Hyperlinks and Anchor in HTML? Explain with suitable example. [5]

Ans

HTML Links - Hyperlinks

HTML links are hyperlinks.

You can click on a link and jump to another document.

When you move the mouse over a link, the mouse arrow will turn into a little hand.

Note: A link does not have to be text. It can be an image or any other HTML element.

HTML Links - Syntax

In HTML, links are defined with the <a> tag:

<a href="url">link text</a>

Example

<a href="https://www.w3schools.com/html/">Visit our HTML tutorial</a>

The href attribute specifies the destination address (https://www.w3schools.com/html/) of the

link.

The link text is the visible part (Visit our HTML tutorial).

Clicking on the link text will send you to the specified address.

Note: Without a forward slash at the end of subfolder addresses, you might generate two requests

to the server. Many servers will automatically add a forward slash to the end of the address, and

then create a new request.

Page 3: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

Local Links

The example above used an absolute URL (a full web address).

A local link (link to the same web site) is specified with a relative URL (without https://www....).

Example

<a href="html_images.asp">HTML Images</a>

HTML Links - The target Attribute

The target attribute specifies where to open the linked document.

The target attribute can have one of the following values:

_blank - Opens the linked document in a new window or tab

_self - Opens the linked document in the same window/tab as it was clicked (this is default)

_parent - Opens the linked document in the parent frame

_top - Opens the linked document in the full body of the window

framename - Opens the linked document in a named frame

Q2a) Write an HTML Page and also provide a JavaScript for accepting a user ID and Password

from the user to ensure the input is not empty[5]

Ans: <html><head>

<script>

Function check()

{

Var a=document.f1.t1.value;

Var b=document.f1.t2.value;

If(a = = ‘ ‘ || b == ‘ ‘){

Alert (“Kindly enter data for username and password”); }

Else{

Alert (“Thank you for entering username and password”); } }

</script>

</head>

<body>

<form name=”f1”>

Username: <input type=”text” name=”t1”required>

Password<input type=”password” name=”t2” required>

<input type=”button” value=”Login” onclick=”check()”>

</form>

</body></html>

Page 4: MOCK-ENDSEM Paper Solution - WordPress.com

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.

Page 5: MOCK-ENDSEM Paper Solution - WordPress.com

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

the form of Login.html file. [5]

Ans:

Login.html

<html>

<body>

<form method=”post” action=”s1”>

Username: <input type=”text” name=”t1” required>

Password<input type=”password” name=”t2” required>

<input type=”submit”>

</form>

</body>

</html>

S1.java

import java.io.*;

import javax.servlet.*;

public class s2 extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException

{

response.setContentType("text/html");

PrintWriter out= response.getWriter();

String un= request.getParameter("t1");

String pw= request.getParameter("t2");

}

}

Q4b) Define the terms : 1. Website, 2.Web Page, 3. URL, 4. Home Page, 5. Web Server?[5]

Ans:

1. Website: A website is a collection of related web pages, including multimedia content,

typically identified with a common domain name, and published on at least one web server.

A website may be accessible via a public Internet Protocol (IP) network, such as the Internet,

or a private local area network (LAN)

2. Web Page: A web page or web page is a document commonly written in HyperText Markup

Language (HTML) that is accessible through the Internet or other network using an Internet

browser. A web page is accessed by entering a URL address and may contain text, graphics,

and hyperlinks to other web pages and files. The page you are reading now is an example of

a web page.

3. Web Server: Web server is a computer where the web content is stored. Basically web

server is used to host the web sites. A Web server is a program that uses HTTP (Hypertext

Transfer Protocol) to serve the files that form Web pages to users, in response to their

requests, which are forwarded by their computers' HTTP clients.

Page 6: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

4. URL: A URL (Uniform Resource Locator), as the name suggests, provides a way to locate a

resource on the web, the hypertext system that operates over the internet. The URL

contains the name of the protocol to be used to access the resource and a resource name.

The first part of a URL identifies what protocol to use. The second part identifies the IP

address or domain name where the resource is located.

5. Home Page: A home page or a start page is the initial or main web page of a website or a

browser.

Q5a) What are technologies used in traditional web programming? Also identify location of

each technology used in this model.[6]

Ans:

HTML- HTML is a markup language. It provides the structure of a website so that web browsers

know what to show.

CSS-CSS is a Cascading Style Sheet. CSS let’s web designers change colors, fonts, animations, and

transitions on the web. They make the web look good.

Programming Languages

Programming languages are ways to communicate to computers and tell them what to do. Below

are just some of the languages and links to their homepages

Javascript - used by all web browsers, Meteor, and lots of other frameworks

Python -used by the Django framework and used in a lot of mathematical calculations

Ruby - used by the Ruby on Rails framework

PHP - used by Wordpress

Java - Used by Android (Google) and a lot of desktop applications.

Frameworks

Frameworks are built to make building and working with programming languages easier.

Frameworks typically take all the difficult, repetitive tasks in setting up a new web application and

either does them for you or make them very easy for you to do.

Node.js - a server-side javascript framework

Ruby on Rails - a full-stack framework built using ruby

Django - a full-stack framework built using python

Bootstrap - a UI (user interface) framework for building with HTML/CSS/Javascript

Wordpress - a CMS (content management system) built on PHP. Currently, about 20% of all

websites run on this framework

Drupal - a CMS framework built using PHP.

.NET - a full-stack framework built by Microsoft

Page 7: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

Angular.js - a front-end javascript framework.

Libraries

Libraries are groupings of code snippets to enable a large amount of functionality without having to

write it all by yourself. Libraries typically also go through the trouble to make sure the code is

efficient and works well across browsers and devices (not always the case, but typically they do).

jQuery

Databases

Databases are where all your data is stored.

MongoDB - is an open-sourced NoSQL database and is currently the only database

supported by Meteor.

MySQL - is another popular open-sourced SQL database. MySQL is used in Wordpress

websites.

Oracle - is an enterprise SQL database.

SQL Server - is an SQL server manager created by Microsoft.

Client (or Client-side)

A client is one user of an application. It’s you and me when we visit http://google.com. Client’s can

be desktop computers, tablets, or mobile devices. There are typically multiple clients interacting

with the same application stored on a server.

Server (or Server-side)

A server is where the application code is typically stored. Requests are made to the server from

clients, and the server will gather the appropriate information and respond to those requests.

Front-end

The front-end is comprised of HTML, CSS, and Javascript. This is how and where the website is

shown to users.

Back-end

The back-end is comprised of your server and database. It’s the place where functions, methods,

and data manipulation happens that you don’t want the clients to see.

Page 8: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution Protocols

Protocols are standardized instructions for how to pass information back and forth between

computers and devices.

HTTP - This protocol is how each website gets to your browser. Whenever you type a

website like “http://google.com” this protocol requests the website from google’s server

and then receives a response with the HTML, CSS, and javascript of the website.

REST - is a protocol mainly used for API’s. It has standard methods like GET, POST, and PUT

that let information be exchanged between applications.

API

An API is an application programming interface. It is created by the developer of an application to

allow other developers to use some of the application’s functionality without sharing code.

Developers expose “end points” which are like inputs and outputs of the application. Using an API

can control access with API keys. Examples of good API’s are those created by Facebook, Twitter,

and Google for their web services.

Data formats

Data formats are the structure of how data is stored.

JSON - is quickly becoming the most popular data format

XML - was the main data format early in the web days and predominantly used by Microsoft

systems

CSV - is data formatted by commas. Excel data is typically formatted this way.

Q5b) What is an Associative array in PHP ? Create associative array for Name and Age.[6]

Ans:

In PHP, there are three types of arrays:

Indexed arrays - Arrays with a numeric index

Associative arrays - Arrays with named keys

Multidimensional arrays - Arrays containing one or more arrays

Associative arrays are arrays that use named keys that you assign to them.

There are two ways to create an associative array:

Page 9: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

1. $age['Peter'] = "35";

$age['Ben'] = "37";

$age['Joe'] = "43";

The named keys can then be used in a script:

2. <?php

$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");

echo "Peter is " . $age['Peter'] . " years old.";

?>

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 ?>

Page 10: MOCK-ENDSEM Paper Solution - WordPress.com

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

Page 11: MOCK-ENDSEM Paper Solution - WordPress.com

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:

Page 12: MOCK-ENDSEM Paper Solution - WordPress.com

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:

Page 13: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution <html><head>

<meta charset="utf-8" />

<title>Angular Demo</title>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<script type="text/javascript">

var myApp= angular.module("AngularApp",[]);

myApp.controller("HelloController", function($scope){

$scope.txtname = "";

});

</script></head>

<body ng-app="AngularApp" ng-controller="HelloController">

<input type="text" ng-model = "txtname">

<p>Hello, Input Name : {{txtname}}</p>

</div>

</body></html>

Q7b) What are different configurations files are require to develop any strut application?

Explain each configuration file. [6]

Ans:

Basic configuration which is required for a Struts 2 application.

1. web.xml,

2. struts.xml,

3. struts-config.xml,

4. struts.properties

The web.xml File

The web.xml configuration file is a J2EE configuration file that determines how elements of the

HTTP request are processed by the servlet container.

It is not strictly a Struts2 configuration file, but it is a file that needs to be configured for Struts2

to work. This file provides an entry point for any web application

The web.xml file needs to be created under the folder WebContent/WEB-INF.

The Struts.xml File

The struts.xml file contains the configuration information that you will be modifying as actions

are developed.

This file can be used to override default settings for an application, for example struts.devMode

= false and other settings which are defined in property file.

This file can be created under the folder WEB-INF/classes.

The first thing to note is the DOCTYPE.

Page 14: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

<struts> is the root tag element, under which we declare different packages using <package>

tags.

The Struts-config.xml File

The struts-config.xml configuration file is a link between the View and Model components in the

Web Client

The configuration file basically contains following main elements −

struts-config- This is the root node of the configuration file.

form-beans-This is where you map your ActionForm subclass to a name.

action-mappings-This is where you declare form handlers

Controller-This section configures Struts internals

plug-in-This section tells Struts where to find your properties files, which contain

prompts and error messages

The Struts.properties File

This configuration file provides a mechanism to change the default behavior of the framework.

you can create this file under the folder WEB-INF/classes.

The values configured in this file will override the default values configured in

default.properties which is contained in the struts2-core-x.y.z.jar distribution.

Q7C) List & explain various directives in AngularJS[4M]

Ans:

AngularJS Directives

We used directives in our first AngularJS application section. Here, we will learn directives in detail.

Directives are markers on a DOM element that tell AngularJS to attach a specified behavior to that

DOM element or even transform the DOM element and its children. In short, it extends the HTML.

Most of the directives in AngularJS are starting with ng- where ng stands for Angular. AngularJS

includes various built-in directives. In addition to this, you can create custom directives for your

application.

The following table lists the important built-in AngularJS directives.

Directive Description

ng-app Auto bootstrap AngularJS application.

Page 15: MOCK-ENDSEM Paper Solution - WordPress.com

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

Page 16: MOCK-ENDSEM Paper Solution - WordPress.com

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']);

mainApp.config(['$routeProvider', function($routeProvider) {

$routeProvider

.when('/addStudent', {

templateUrl: 'addStudent.htm', controller: 'AddStudentController'

})

.when('/viewStudents', {

templateUrl: 'viewStudents.htm', controller: 'ViewStudentsController'

})

.otherwise ({

Page 17: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution redirectTo: '/addStudent'

});

}]);

Q8b) List & explain events supported by AngularJS to enrich form filling & validations.[6]

Ans: AngularJS provides multiple events associated with the HTML controls. For example, ng-click

directive is generally associated with a button. AngularJS supports the following events −

ng-click

ng-dbl-click

ng-mousedown

ng-mouseup

ng-mouseenter

ng-mouseleave

ng-mousemove

ng-mouseover

ng-keydown

ng-keyup

ng-keypress

ng-change

ng-click:

The ng-click directive is used to provide event handler for click event.

Validate data

Following can be used to validate the data.

ng-valid is set if the form is valid.

ng-invalid is set if the form is invalid.

ng-pending is set if the form is pending.

ng-pristine is set if the form is pristine.

ng-dirty is set if the form is dirty.

ng-submitted is set if the form was submitted.

Q8c) Explain NodeJS in detail. [4]

Ans:

What is Node.js?

Node.js is an open source server environment

Node.js is free

Page 18: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)

Node.js uses JavaScript on the server

Why Node.js?

Node.js uses asynchronous programming!

A common task for a web server can be to open a file on the server and return the content to the

client.

Here is how PHP or ASP handles a file request:

1. Sends the task to the computer's file system.

2. Waits while the file system opens and reads the file.

3. Returns the content to the client.

4. Ready to handle the next request.

Here is how Node.js handles a file request:

1. Sends the task to the computer's file system.

2. Ready to handle the next request.

3. When the file system has opened and read the file, the server returns the content to the

client.

Node.js eliminates the waiting, and simply continues with the next request.

Node.js runs single-threaded, non-blocking, asynchronously programming, which is very memory

efficient.

What Can Node.js Do?

Node.js can generate dynamic page content

Node.js can create, open, read, write, delete, and close files on the server

Node.js can collect form data

Node.js can add, delete, modify data in your database

What is a Node.js File?

Node.js files contain tasks that will be executed on certain events

A typical event is someone trying to access a port on the server

Node.js files must be initiated on the server before having any effect

Node.js files have extension ".js"

Page 19: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

Q9a) Draw & explain scenario of client accessing remote EJB. List some of the EJB clients.[8]

Ans

An EJB client accesses the business logic contained in the EJBs, in this general way:

1. The EJB client uses a naming service to locate the EJB's home interface.

2. The naming service (usually the Java™ Naming and Directory Interface, JNDI) returns a

reference to an object that implements the EJB's home interface (described in How an EJB

Client Accesses EJBs).

3. The EJB client makes a call on the EJB's home interface, to gain access to the EJB's remote

interface (described in How an EJB Client Accesses EJBs).

4. The EJB client make calls to the EJB's business methods against the remote interface.

However, the actual code you use to access an EJB from an EJB client will vary according to the type

of Web Application Server you are using.

Figure 1 shows how the EJBClient sample application accesses the EJBs via their home interfaces

(shown as H), and remote interfaces (shown as R). If you wish to see the complete code for

accessing the EJBs using the EJB Client, refer to the VSE Connector Client online documentation.

Figure 1. How the EJB Client Accesses EJBs in the Provided Example

Page 20: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

The two session beans are in fact themselves EJB clients. When accessing the RecordBean, they

perform the same processing of looking up the home interface and remote interface, as the EJB

client does when it gets access to the session beans.

The session beans implement two different views on the same data, by including or not a particular

column into a view. In addition, however, the session beans specify access rights for specific

columns. For example, the EmployeeBean might only be able to read a given column, whereas the

EmployerBean might also be able to update this column.

Q9b) What are different types of EJB? Identify & explain situations about when to use session

beans.[6]

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.

Types of EJB Beans

Page 21: MOCK-ENDSEM Paper Solution - WordPress.com

Class: TE Computer Subject: Web Technology 2018-19 SEM II Staff Name: Prof. B.A.Khivsara MOCK-ENDSEM Paper Solution

S.No Type & Description

1

Session Bean

Session bean stores data of a particular user for a single session.

It can be stateful or stateless.

It is less resource intensive as compared to entity bean.

Session bean gets destroyed as soon as user session terminates.

2

Entity Bean

Entity beans represent persistent data storage.

User data can be saved to database via entity beans and later on can be retrieved

from the database in the entity bean.

3

Message Driven Bean

Message driven beans are used in context of JMS (Java Messaging Service).

Message Driven Beans can consumes JMS messages from external entities and act

accordingly.

When to use Session beans:

A session bean tends to be responsible for a group of related functionality. For example, an

application for an educational institution might have a session bean whose methods contain logic

for handling student records. Another session bean might contain logic that maintains the lists of

courses and programs available at that institution.

There are two types of session beans, which are defined by their use in a client interaction:

Page 22: MOCK-ENDSEM Paper Solution - WordPress.com

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

Page 23: MOCK-ENDSEM Paper Solution - WordPress.com

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

Page 24: MOCK-ENDSEM Paper Solution - WordPress.com

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.

Page 25: MOCK-ENDSEM Paper Solution - WordPress.com

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.

Page 26: MOCK-ENDSEM Paper Solution - WordPress.com

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

Page 27: MOCK-ENDSEM Paper Solution - WordPress.com

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