IP - Models - Answer Key
IP - Models - Answer Key
(OR)
(b) Demonstrate the techniques used to optimize website assets loading.
Tips To Improve Web Optimization
1. Prefetching should be enabled
2. Provide fast loading times
3. Scripts should be placed at the bottom and style sheets at the top
4. Asynchronous Scripts
5. Reduce HTTP requests by combining JavaScript and CSS files
6. Files should be compressed
7. Prioritize mobile-first Approach
8. Make use of web
9. Utilize a CDN service
10. Reduce HTTP requests
12. (a) Demonstrate use of JSON. How to convert JavaScript objects to JSON ? List the benefits of
JSON over XML
Uses of JSON:
It is used while writing JavaScript based applications that includes browser extensions and websites.
JSON format is used for serializing and transmitting structured data over network connection.
It is primarily used to transmit data between a server and web applications.
Web services and APIs use JSON format to provide public data.
It can be used with modern programming languages.
The JSON format is syntactically similar to the code for creating JavaScript objects. Because of this,
a JavaScript program can easily convert JSON data into JavaScript objects.Since the format is text
only, JSON data can easily be sent between computers, and used by any programming language.
1. JSON requires less tags than XML – XML items must be wrapped in open and close tags whereas
JSON you just name the tag once
2. Because JSON is transportation-independent, you can just bypass the XMLHttpRequest object for
getting your data.
3. JavaScript is not just data – you can also put methods and all sorts of goodies in JSON format.
4. JSON is better at helping procedural decisions in your JavaScript based on objects and their values
(or methods).
5. You can get JSON data from anywhere, not just your own domain. There’s no more proxy server
nonsense.
6. JSON is easier to read than XML
(OR)
(b) Whether JavaScript a statically types or dynamically typed language. Justify your answer with
examples.
A language with static types is referred to as a statically-typed language. On the other hand, a language
with dynamic types is referred to as a dynamically-typed language. The core difference is that statically-
typed languages perform type checking at compile time, while dynamically-typed languages perform type
checking at runtime. This leaves one more concept for you to tackle: what does “type-checking” mean?
To explain, let’s look at types in Java versus Javascript.
Long story short: statically-typed languages require you to declare the data types of your constructs before you
can use them. Dynamically-typed languages do not. JavaScript implies the data type, while Java states it
outright.So as you can see, types allow you to specify program invariants, or the logical assertions and
conditions under which the program will execute.
Type-checking verifies and enforces that the type of a construct (constant, boolean, number, variable,
array, object) matches an invariant that you’ve specified. You might, for example, specify that “this function
always returns a string.” When the program runs, you can safely assume that it will return a string.
The differences between static type checking and dynamic type checking matter most when a type error occurs.
In a statically-typed language, type errors occur during the compilation step, that is, at compile time. In
dynamically-typed languages, the errors occur only once the program is executed. That is, at runtime.
This means that a program written in a dynamically-typed language (like JavaScript or Python) can compile
even if it contains type errors that would otherwise prevent the script from running properly.
13 (a) Demonstrate the Single-Threaded Model in Servlets. How does Servlets Collaboration take
place?
Single Thread Model Interface was designed to guarantee that only one thread is executed at a
time in a given servlet instance service method. It should be implemented to ensure that the servlet can
handle only one request at a time. It is a marker interface and has no methods. Once the interface is
implemented the system guarantees that there’s never more than one request thread accessing a single
instance servlet. This interface is currently deprecated because this doesn’t solve all the thread safety
issues such as static variable and session attributes can be accessed by multiple threads at the same
time even if we implemented the SingleThreadModel interface. That’s why to resolve the thread-
safety issues it is recommended to use a synchronized block .
Syntax:
public class Myservlet extends Httpservlet implements SingleThreadModel {
}
Implementation: SingleThreadModel interface
We created three files to make this application:
1. index.html
2. Myservlet.java
3. web.xml
The index.html file creates a link to invoke the servlet of URL-pattern “servlet1” and Myservlet class extends
HttpServlet and implements the SingleThreadModel interface. Class Myservlet is a servlet that handles Single
requests at a single time and sleep() is a static method in the Thread class used to suspend the execution of a
thread for two thousand milliseconds. When another user will try to access the same servlet, the new instance
is created instead of using the same instance for multiple threads.
(OR)
(b) Illustrate about the following with an example.
a. JSP and Servlet
Servlet technology is used to create a web application. A servlet is a Java class that is used to
extend the capabilities of servers that host applications accessed by means of a request-response
model. Servlets are mainly used to extend the applications hosted by web services.
JSP is used to create web applications just like Servlet technology. A JSP is a text document that
contains two types of text: static data and dynamic data. The static data can be expressed in any
text-based format (like HTML, XML, SVG, and WML), and the dynamic content can be
expressed by JSP elements
Apache Tomcat Server(Jakarta Tomcat): It is an open source web server and servlet container
developed by the Apache Software Foundation (ASF). It implements the Java Servlet and the JavaServer
Pages (JSP) specifications and provides a pure Java HTTP web server environment for java code to run.
JavaServerPages(JSP): It is a technology that helps in creating dynamically generated web pages.
Step1
Install Java.
Step2
InstallApacheTomcat
At the time of installation, it will by-default recognize JRE path.(under installed java location directory)
Step3
Now Go-To:
Start
Programs
APACHE TOMCAT
MONITOR TOMCAT
Step4
An icon will appear on the taskbar, this icon will automatically appear after following above step:
Step5
Click on that icon and START TOMCAT, you can see the following dialog box:
Step6
Now open Mozilla Firefox(or any other browser)
Step7
Type http://localhost:8080/ on address bar and press enter.
(if not, then try again, may be a problem in installation or you’re not following above steps correctly
Step9
Now, go to:
C:drive
Programs Files
Apache Software Foundation
tomcat
web-apps
Step10
Open web-apps and “copy your project” or “make new folder”, which you want to run in JSP.
Example: amit2012PROJECT
Tomcat
Root
Copy Web-inf from root
Paste this “web-inf” in your project folder i.e. amit2012PROJECT
Step11
Create a text file and name it as first.jsp,
14. (a) Demonstrate the features of built-in functions in PHP with examples
(OR)
(b) Explain about DOM with the XML data processing.
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs
and scripts to dynamically access and update the content, structure, and style of a document."
The HTML DOM defines a standard way for accessing and manipulating HTML documents. It presents an
HTML document as a tree-structure.The XML DOM defines a standard way for accessing and manipulating
XML documents. It presents an XML document as a tree-structure.Understanding the DOM is a must for
anyone working with HTML or XML.
Example
<h1 id="demo">This is a Heading</h1>
<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>
This example changes the value of the first <h1> element in an HTML document:
Example
<h1>This is a Heading</h1>
<h1>This is a Heading</h1>
<script>
document.getElementsByTagName("h1")[0].innerHTML = "Hello World!";
</script>
15. (a) Demonstrate about the structure of a WSDL document , its elements and their purposes with
appropriate examples
The WSDL Document Structure
The main structure of a WSDL document looks like this −
<definitions>
<types>
definition of types........
</types>
<message>
definition of a message....
</message>
<portType>
<operation>
definition of a operation.......
</operation>
</portType>
<binding>
definition of a binding....
</binding>
<service>
definition of a service....
</service>
</definitions>
(OR)
(b) Demonstrate about the AJAX client-server architecture with neat diagram
Components of JDBC
JDBC has four major components that are used for the interaction with the database.
1. JDBC API
2. JDBC Test Suite
3. JDBC Driver Manger
4. JDBC ODBC Bridge Driver
(OR)
It is important for web applications to be able to communicate over the Internet.The best way to communicate
between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was
created to accomplish this.SOAP provides a way to communicate between applications running on different
operating systems, with different technologies and programming languages.
Syntax Rules
The required SOAP Envelope element is the root element of a SOAP message. This element defines the XML
document as a SOAP message.