0% found this document useful (0 votes)
48 views9 pages

Web Technology Insem - 2019 Pattern

The document discusses key concepts related to web technologies including: 1. It defines common terms like website, web page, web server, URL, and home page. 2. It explains the difference between internal and external DTDs, with examples of each. 3. It discusses XML schemas and how they are better than DTDs, listing some advantages of schemas. 4. It provides examples to explain the difference between JavaScript and jQuery. 5. It includes an HTML page with JavaScript validation to check for empty user ID and password fields.

Uploaded by

rajjarad01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views9 pages

Web Technology Insem - 2019 Pattern

The document discusses key concepts related to web technologies including: 1. It defines common terms like website, web page, web server, URL, and home page. 2. It explains the difference between internal and external DTDs, with examples of each. 3. It discusses XML schemas and how they are better than DTDs, listing some advantages of schemas. 4. It provides examples to explain the difference between JavaScript and jQuery. 5. It includes an HTML page with JavaScript validation to check for empty user ID and password fields.

Uploaded by

rajjarad01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.

Khivsara
INSEM Paper Solution

Q1a) Define the terms [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.
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.

Q1 b) Explain difference between Internal and External DTD. [5]

Internal DTD External DTD


You can write rules inside XML document using You can write rules in a separate file (with .dtd
declaration. Scope of this DTD within this extension). later this file linked to a XML
document. document
Advantages is document validated by itself This way you can linked several XML documents
without external reference. refer same DTD rules.

Example: <?xml version=”1.0″ <?xml version=”1.0″ standalone=”no”?>


standalone=”yes”?> <!DOCTYPE courses SYSTEM “courses.dtd”>
<!DOCTYPE courses [ <courses >
<!ELEMENT courses (course)+> <course>
<!ELEMENT course (date,url)> <name>XML Course</name>
<!ELEMENT date (#PCDATA)> <url>http://www.teach.com/xml/course</url>
<!ELEMENT url (#PCDATA)>] </course>
<courses > <course>
<course> <name>Java Course</name>
<name>XML Course</name> <url>http://www.teach.com/java/course</url>
<url>http://www.teach.com/xml/course</url> </course>
</course> </courses >
<course>
<name>Java Course</name> “courses.dtd” file is the following.
<url>http://www.teach.com/java/course</url> <!ELEMENT courses (course)+>
</course> <!ELEMENT course (date,url)>
</courses > <!ELEMENT date (#PCDATA)>
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution

<!ELEMENT url (#PCDATA)>

Q2a) what are XML Schemas? How are they better that DTD. [5]
Ans:
DTD, or Document Type Definition, and XML Schema, which is also known as XSD, are two ways of describing
the structure and content of an XML document. DTD is the older of the two, and as such, it has limitations that
XML Schema has tried to improve.

Reasons about why XSD are better than DTD:

1. XML Schema is namespace aware, while DTD is not.

2. XML Schemas are written in XML, while DTDs are not.

3. XML Schema is strongly typed, while DTD is not.

4. XML Schema has a wealth of derived and built-in data types that are not available in DTD.

5. XML Schema does not allow inline definitions, while DTD does.

Q2b) List and describe any five HTML tags. [5]


Ans:

Basic HTML
Tag Description
<!DOCTYPE> Defines the document type
<html> Defines an HTML document
<head> Defines information about the document
<title> Defines a title for the document
<body> Defines the document's body
<h1> to <h6> Defines HTML headings
<p> Defines a paragraph
<br> Inserts a single line break
<hr> Defines a thematic change in the content
<!--...--> Defines a comment

Forms and Input


Tag Description
<form> Defines an HTML form for user input
<input> Defines an input control
<textarea> Defines a multiline input control (text area)
<button> Defines a clickable button
<select> Defines a drop-down list

Frames
Tag Description
<frame> Not supported in HTML5.
Defines a window (a frame) in a frameset
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution

<frameset> Not supported in HTML5.


Defines a set of frames

Images
Tag Description
<img> Defines an image
<area> Defines an area inside an image-map

Lists
Tag Description
<ul> Defines an unordered list
<ol> Defines an ordered list
<li> Defines a list item
<dl> Defines a description list
<dt> Defines a term/name in a description list
<dd> Defines a description of a term/name in a description list

Q3a) Explain difference between JavaScript and JQuery. [5]


Ans:
 jQuery is a framework that lets you write JavaScript quicker and easier.
 The developers of jQuery created it to condense common JavaScript tasks into fewer lines of code.
 You can code most common JavaScript actions using jQuery (and you can actually check out their API
page for a complete list of what you can do)
 It’s easy to install and get the code to understand jQuery.
 Remember that the biggest difference between jQuery and JavaScript is that jQuery has been
optimized to work with a variety of browsers automatically. Unfortunately, JavaScript still has some
issues with cross-browser compatibility due to poor JavaScript implementation practices on the part
of web browser developers.
 Example: is designed to change the background color of a body tag using jQuery and JavaScript
respectively:

jQuery
$ (‘body’) .css (‘background’, ‘#ccc’);

JavaScript
Function changeBachground(color) {
Document.body.style.background = color;

}
Onload=”changeBackground (‘red’);”
jQuery code is much simpler and smaller as complared to JavaScript

Q3b) Write a 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>
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution

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>

Q4a) What is the purpose of DOM node tree? Draw node tree for simple HTMl page. [5]
Ans:

The HTML DOM views a HTML document as a tree-structure. The tree structure is called a node-tree.
All nodes can be accessed through the tree. Their contents can be modified or deleted, and new elements can
be created.
The node tree below shows the set of nodes, and the connections between them. The tree starts at the root
node and branches out to the text nodes at the lowest level of the tree:

Node Parents, Children, and Siblings

The nodes in the node tree have a hierarchical relationship to each other.

The terms parent, child, and sibling are used to describe the relationships. Parent nodes have children.
Children on the same level are called siblings (brothers or sisters).
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution

 In a node tree, the top node is called the root


 Every node, except the root, has exactly one parent node
 A node can have any number of children
 A leaf is a node with no children
 Siblings are nodes with the same parent

Look at the following HTML fragment:

<html>
<head>
<title>DOM Tutorial</title>
</head>
<body>
<h1>DOM Lesson one</h1>
<p>Hello world!</p>
</body>
</html>

In the HTML above, every node except for the document node has a parent node:

 The <html> node has no parent node; the root node


 The parent node of the <head> and <body> nodes is the <html> node
 The parent node of the "Hello world!" text node is the <p> node

Most element nodes have child nodes:

 The <html> node has two child nodes; <head> and <body>
 The <head> node has one child node; the <title> node
 The <title> node also has one child node; the text node "DOM Tutorial"
 The <h1> and <p> nodes are siblings, and both child nodes of <body>

Q4 b) List and brief any five functions in JavaScript. [5]


Ans:

1. Popping- The pop() method removes the last element from an array:

Example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop(); // Removes the last element ("Mango") from fruits

2. Pushing- The push() method adds a new element to an array (at the end):

Example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi"); // Adds a new element ("Kiwi") to fruits
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution

3. Sorting an Array-The sort() method sorts an array alphabetically:

Example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort(); // Sorts the elements of fruits

4. The slice() Method- slice() extracts a part of a string and returns the extracted part in a new
string.

The method takes 2 parameters: the starting index (position), and the ending index (position).
This example slices out a portion of a string from position 7 to position 13:

Example
var str = "Apple, Banana, Kiwi";
var res = str.slice(7, 13); // returns Banana

5. Math.round()- Math.round(x) returns the value of x rounded to its nearest integer:

Example
Math.round(4.7); // returns 5

6. Math.pow()-Math.pow(x, y) returns the value of x to the power of y:

Example
Math.pow(8, 2); // returns 64

Q5a)Write advantages of JSP over servlets? Also explain life cycle of a JSP. [5]
Ans:
Advantage of JSP over Servlet
• 1) Extension to Servlet
• JSP technology is the extension to servlet technology. We can use all the features of servlet in JSP. In
addition to, we can use implicit objects, predefined tags, expression language and Custom tags in JSP,
that makes JSP development easy.
• 2) Easy to maintain
• JSP can be easily managed because we can easily separate our business logic with presentation logic.
In servlet technology, we mix our business logic with the presentation logic.
• 3) Fast Development: No need to recompile and redeploy
• If JSP page is modified, we don't need to recompile and redeploy the project. The servlet code needs to
be updated and recompiled if we have to change the look and feel of the application.
• 4) Less code than Servlet
• In JSP, we can use a lot of tags such as action tags, jstl, custom tags etc. that reduces the code.
Moreover, we can use EL, implicit objects etc.
Life cycle of a JSP Page
• The JSP pages follows these phases:
• Translation of JSP Page
• Compilation of JSP Page
• Classloading (class file is loaded by the classloader)
• Instantiation (Object of the Generated Servlet is created).
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution

• Initialization ( jspInit() method is invoked by the container).


• Reqeust processing ( _jspService() method is invoked by the container).
• Destroy ( jspDestroy() method is invoked by the container).

Q5b)Create a servlet in java and get userID and password parameter which are entered in Login.html
file. [5]
Ans:

Login.html
<html>
<body>
<form method=”post” action=”loginServlet”>
Username: <input type=”text” name=”t1” required>
Password<input type=”password” name=”t2” required>
<input type=”Submit” value=”Login” >
</form>
</body>
</html>

loginServlet.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class First extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws


ServletException, IOException {
PrintWriter pw=response.getWriter();
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution
response.setContentType("text/html");

String uname=request.getParameter("t1");
String pass =request.getParameter("t1");
pw.println("User Name is"+uname);
pw.println("Password is"+pass);
pw.close();
}

Q6a)_ 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>

Q6b) What are the usage of JSP Directives and JSP Actions. [5]
Ans:

A JSP directive affects the overall structure of the servlet class. It usually has the following form −

<%@ directive attribute = "value" %>

Directives can have a number of attributes which you can list down as key-value pairs and separated by
commas.

The blanks between the @ symbol and the directive name, and between the last attribute and the closing
%>, are optional.

There are three types of directive tag −

S.No. Directive & Description


1 <%@ page ... %>
Defines page-dependent attributes, such as scripting language, error page, and buffering
requirements.
2 <%@ include ... %>
Includes a file during the translation phase.
Class: TE Computer Subject: Web Technology 2017-18 SEM II Staff Name: Prof. B.A.Khivsara
INSEM Paper Solution

3 <%@ taglib ... %>


Declares a tag library, containing custom actions, used in the page

Actions in JSP: These actions use constructs in XML syntax to control the behavior of the servlet engine.
You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or
generate HTML for the Java plugin.

There is only one syntax for the Action element, as it conforms to the XML standard −

<jsp:action_name attribute = "value" />

Action elements are basically predefined functions. The following table lists out the available JSP actions −

S.No. Syntax & Purpose


1 jsp:include- Includes a file at the time the page is requested.
2 jsp:useBean- Finds or instantiates a JavaBean.
3 jsp:setProperty-Sets the property of a JavaBean.
4 jsp:getProperty-Inserts the property of a JavaBean into the output.
5 jsp:forward-Forwards the requester to a new page.
6 jsp:plugin-Generates browser-specific code that makes an OBJECT or EMBED tag for the
Java plugin.
7 jsp:element-Defines XML elements dynamically.
8 jsp:attribute-Defines dynamically-defined XML element's attribute.
9 jsp:body-Defines dynamically-defined XML element's body.
10 jsp:text-Used to write template text in JSP pages and documents.

You might also like