Web Technology Insem - 2019 Pattern
Web Technology Insem - 2019 Pattern
Khivsara
INSEM Paper Solution
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.
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.
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
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
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
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:
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
<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 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>
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
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
Example
Math.round(4.7); // returns 5
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
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;
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 −
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.
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 −
Action elements are basically predefined functions. The following table lists out the available JSP actions −