Web Technology Suggestions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

Page |1

Web Technology Suggestions


1. Full form of:
a. SOAP b. RMI c. JNI d. JIDI e. JNDI f. EJB

Ans:
a. SOAP: Simple Object Access Protocol
b. RMI: Remote Method Invocation
c. JNI: Java Native Interface
d. JINI: Java Intelligent Network Infrastructure
e. JNDI: Java Naming and Directory Interface API
f. EJB: Enterprise Java Beans

2. What do you mean by static and dynamic web pages?


Ans:
Static Web Pages:
Static Web Pages is very simple, it is written in languages such as HTML, CSS,
JavaScript, etc. For static web pages when a server receives a request for a web page,
then the server sends the response to the client without doing any additional
process. Pages remains the same until someone changes it manually.

Dynamic Web Pages:


Dynamic Web Pages are written in languages such as CGI, AJAX, ASP.NET, etc. in
dynamic web pages, the content of the pages is different for different visitors. It
takes more time to load than the static web page. Dynamic web pages are used
where the information is changed frequently, for example, stock prices, weather
information, etc.
Page |2

Static Web Page Dynamic Web Page


Prebuilt content is same every Content is generated quickly and
time the page is loaded. changes regularly.
It uses the HTML code for It uses the server side languages
developing a website such as PHP, Servlet, JSP, and
ASP.net etc for developing a
website.
It sends exactly the same It may generate different HTML for
response for every request. each of the request.
The content is only changes when The page contains “server-side”
someone publishes and updates code which allows the server to
the file (sends it to the web generate the unique content when
server). the page is loaded.
Flexibility is the main advantage Content Management System
of static website. (CMS) is the main advantage of
dynamic website.

3. What are the advantages of Dynamic Website over Static Website?


Ans: The advantages of dynamic website over static website are as follows:
• Better user experience: A dynamic website is designed to be very user-
friendly, allowing users to easily make changes to the website depending on
their requirements.

• Easier maintenance: A content management system that has the database for
all elements, is used for dynamic websites. They also use scripting languages
that primarily interact with all the database’s information, making it possible
to execute site-wide changes without needing to do changes one by one.
Page |3

• Easy updating: One of the most sought-after benefits of building a dynamic


website is that it lets us to update our information/content easily depending
upon our requirements.

• Professional looking: Dynamic websites gives us an elevated look and seem


more professional than static websites. This is usually because static sits lack
quite a few features and elements that users expect from modern sites.

• Futuristic: Dynamic websites empower the user to be more involved & engage
with the content of the site. By offering them an interactive and responsive
experience, they elevate them through personalized browsing.

4. What is CGI?
Ans: The common gateway interface (CGI) is a standard way for a Web server to pass
a Web user's request to an application program and to receive data back to forward
to the user. When the user requests a Web page (for example, by clicking on a
highlighted word or entering a Web site address), the server sends back the
requested page. However, when a user fills out a form on a Web page and sends it in,
it usually needs to be processed by an application program. The Web server typically
passes the form information to a small application program that processes the data
and may send back a confirmation message. This method or convention for passing
data back and forth between the server and the application is called the common
gateway interface (CGI). It is part of the Web's Hypertext Transfer Protocol (HTTP).

The common gateway interface provides a consistent way for data to be passed from
the user's request to the application program and back to the user. This means that
the person who writes the application program can makes sure it gets used no
matter which operating system the server uses

It's simply a basic way for information to be passed from the Web server about your
request to the application program and back again.
Because the interface is consistent, a programmer can write a CGI application in a
number of different languages. The most popular languages for CGI applications are:
C, C++, Java and PERL.

Features of CGI:
• It is a very well-defined supported standard.
• CGI scripts are generally written in either Perl, C, or maybe just a simple shell
script/
• CGI is a technology that interfaces with HTML.
Page |4

• CGI standard is generally the most compatible with today’s browsers.

5. Write down the advantages of 3 tier architecture over 2 tier architecture of J2EE.
Ans:
Ans: Following are the advantages of 3 tier architecture.
• It is scalable as each tier can scale in horizontal direction.
• Better re-use is possible.
• Offers higher flexibility as far as configuration and platform deployment is
concerned.
• It improves data integrity.
• It offers higher level of security as client does not have access to the database
directly.
• It is easier to maintain and do any modification.
• Offers good performance as presentation tier does caching operations. This offers
better network utilization and load is reduced on application tier and data tiers.

6. Write down the Servlet Life Cycle. What is the function of init(), service() and
destroy() method in the cycle of Servlet.
Ans: A servlet life cycle can be defined as the entire process from its creation till the
destruction.
The following are the paths followed by a servlet:
• The servlet is initialized by calling the init() method.
• The servlet calls service() method to process a client’s request.
• The servlet is terminated by calling the destroy() method.
• Finally, servlet is garbage collected by the garbage collector of the JVM.

The init() method:


• The init() method is called only once. It is called only when the servlet is
created, and not called for any user requests afterwards. So, it is used for one-
time initializations, just as with the init() method of applets.
Page |5

• The servlet is normally created when a user first involves a URL corresponding
to the servlet, but we can also specify that the servlet be loaded when the
server is first started.
• When a user invokes a servlet, a single instance of each servlet gets created,
with each user request resulting in a new thread that is handled off to doGet
or doPost as appropriate.
• The init() method simply creates or loads some data that will be used
throughout the life of the servlet.
• Example:
public void init() throws ServletException {
// initialization code
}

The service() method


• The service() method is the main method to perform the actual task. The
servlet container (i.e., web server) calls the service() method to handle
request coming from the client (browsers) and to write the formatted
response back to the client.
• Each time the server receives a request for a servlet, the servlet spawns a new
thread and calls service. The service() method checks the HTTP request type
(GET, POST, PUT, DELETE, etc.) and calls doGet, doPost, doPut, doDelete, etc.
methods as appropriate.
• Example:
public void service(ServletRequestrequest, ServletResponse response) throws
ServletException, IOException{
}
• The service() method is called by the container and service method invokes
doGet, doPost, doPut, doDelete, etc., methods as appropriate. So, we have
nothing to do with service() method but we override either doGet() or
doPost() depending on what type of request is received from the client.

The destroy() method


• The destroy() method is called only once at the end of the life cycle of a
servlet, This method gives us servlet a chance to close database connections,
halt background threats, write cookies lists or hit counts to disk, and perform
other such cleanup activities.
• After the destroy() method is called, the servlet object is marked for garbage
collection.
• Example:
public void destroy(){
Page |6

// finalization code…
}

7. Differentiate between:
a. Cookies and Session
b. GET() and POST() method
c. CGI and Servlet
d. Servlet and Applet
e.
Ans:
a. Cookies and Session
Cookies Sessions
Cookies are the client-side files that Sessions are server-side files that
are stored on a local computer and store user information.
contain user information.
Cookies expire after the user The session ends when the user
specified lifetime. closes the browser or logs out of the
program.
It can only store a limited amount of It is able to store an unlimited
data. amount of information.
Cookies can only store upto a There is a maximum memory
maximum of 4 kB of data in a restriction of 128 mB that a script
browser. may consume at one time. However,
we are free to maintain as much
data as we like within a session.
It is necessary for us to execute a Utilizing the session start() method is
function in order to get cookies required before we can begin the
going because they are stored on the session.
local computer.
Cookies are used to store The data is saved in an encrypted
information in a text file. format during sessions.
Cookies are stored on a limited A session can store an unlimited
amount of data. amount of data.

b. GET() and POST() method


HTTP GET HTTP POST
In GET method we can not send In POST method large amount of
large amount of data rather limited data can be sent because the
data is sent because the request request parameter is appended into
parameter is appended into the the body.
URL.
Page |7

GET request is comparatively better POST request is comparatively less


than Post so it is used more than the better than Get so it is used less
than the Get request.
Post request.
GET request is comparatively less POST request is comparatively more
secure because the data is exposed secure because the data is not
in the URL bar. exposed in the URL bar.
Request made through GET method Request made through POST
are stored in Browser history. method is not stored in Browser
history.
GET method request can be saved as POST method request can not be
bookmark in browser. saved as bookmark in browser.
Request made through GET method Request made through POST
are stored in cache memory of method are not stored in cache
Browser. memory of Browser.
Data passed through GET method Data passed through POST method
can be easily stolen by attackers. can not be easily stolen by
attackers.
In GET method only ASCII characters In POST method all types of data is
are allowed. allowed.

c. CGI and Servlet


CGI Servlet
It is process-based i.e., for every new It is thread based i.e., for every new
request new process is created. request new thread is created.
The codes are written in any The codes are written in Java
programming language. programming language.
Since codes are written in any Since codes are written in Java, it is
language, all the languages are not object-oriented and the user will get
object-oriented thread-based. So, the benefits of OOPS.
the user will not get the benefits of
OOPS.
It is not portable. It is portable.
It can use the web-server that It can use any of the web-server.
supports it.
Data sharing is not possible Data sharing is possible.
It does not link the web server It links directly to the server.
directly to the server.
It can neither read nor set HTTP It can read and set HTTP servers.
servers.
It can speed is faster It can speed is slower.
It cannot be platform dependent It can be platform dependent.
Page |8

d. Servlet and Applet


Servlet Applet
Servlets are executed on the server- Applets are executed on client-side
side. i.e., servlet runs on the web i.e., applet runs within a web
page on server. browser on the client machine.
Parent package of servlet includes Parent package of applet includes
javax.servlet.* and java.servlet.* java.applet.* and java.awt.*
Lifecycle methods of servlet are Important methods of applet
init(), service() and destroy() includes init(), stop(), paint(), start(),
destroy().
No such interface is required for the For the execution of the applet, a
execution of servlet user interface is required such as
AWT or swing.
Servlets are executed on the servers The applet requires user interface on
and hence require less bandwidth. the client machine for execution so
it requires more bandwidth.
Servlets are more secure as Applets are more prone to risk as
execution is under server security. execution is on the client machine.

e. D

8. Write short notes on any one:


a. J2EE Architecture
b. WWW
c. JDBC Drivers.
d. MVC Architecture

Ans:
a. J2EE Architecture:
J2EE stands for Java 2 Platform, Enterprise Edition. J2EE is the standard
platform for developing applications in the enterprise and is designed for
enterprise applications that run on servers. J2EE provides APIs that let
developers create workflows and make use of resources such as databases or
web services. J2EE consists of a set of APIs. Developers can use these APIs to
build applications for business computing.

A J2EE application server is software that runs applications built with J2EE APIs
and lets us run multiple applications on a single computer. Developers can use
different J2EE application servers to run applications built with J2EE APIs.

Benefits of J2EE:
Page |9

• Portability: If we build a J2EE application on a specific platform, it runs


the same way on any other J2EE compliant platform. This makes it easy
to move applications from one environment to another.
• Reusability: The components in J2EE are reused, so the average size of
an application is much smaller than it would be if you had to write
equivalent functionality from scratch for each program.
• Security: Java technology lets programmers handle sensitive data far
more securely than they can in C/C++ programs
• Scalability: J2EE lets developers build applications that run well on both
small, single-processor computers and large, multi-processor systems.
• Reliability: Many of the services (such as transaction management and
monitoring) that applications need to be reliable are built into J2EE

Limitations of J2EE:
• J2EE doesn’t provide any database access services.
• You cannot build desktop applications using J2EE APIs; they only run in
application servers and communicate with backend J2EE services
(application servers).
• Application servers often require separate licenses and must be
purchased separately.

b. WWW:
The World Wide Web is abbreviated as WWW and is commonly known as the
web. WWW can be defined as the collection of different websites around the
world, containing different information shared via local servers (or
computers).

From the user’s point of view, the web consists of a vast, worldwide
connection of documents or web pages. Each page may contain links to other
pages anywhere in the world. The browser fetches the page requested
interprets the text and formatting commands on it, and displays the page,
properly formatted, on the screen.

The World Wide Web is based on several different technologies: Web


browsers, Hypertext Markup Language (HTML) and Hypertext Transfer
Protocol (HTTP).

A Web browser is used to access web pages. Web browsers can be defined as
programs which display text, data, pictures, animation and video on the
Internet. Hyperlinked resources on the World Wide Web can be accessed
P a g e | 10

using software interfaces provided by Web browsers. Initially, Web browsers


were used only for surfing the Web but now they have become more
universal. Web browsers can be used for several tasks including conducting
searches, mailing, transferring files, and much more. Some of the commonly
used browsers are Internet Explorer, Opera Mini, and Google Chrome.

c. JDBC Drivers:
JDBC Drivers are client-side adapters (installed on the client machine, not on
the server) that convert requests from Java programs to a protocol that the
DBMS can understand.

There are four types of JDBC Drivers:


• Type-1 Driver or JDBC-ODBC Bridge Driver
• Type-2 Driver or Native-API Driver
• Type-3 Driver or Network Protocol Driver
• Type-4 Driver or Thin Driver

Type – 1 Driver: or JDBC – ODBC Bridge Driver uses ODBC Driver to connect to
the database. The JDBC – ODBC Bridge Driver converts JDBC method calls into
the ODBC function calls. Type – 1 driver is also called Universal Driver because
it can be used to connect to any of the databases. Type – 1 driver isn’t written
in Java, that’s why it isn’t a portable driver. This driver software is built-in with
JDK so no need to install separately. It is a database independent driver.

Type – 2 Driver: This driver converts JDBC method calls into native calls of the
database API. In order to interact with different database, this driver needs
their local API, that’s why data transfer is much more secure as compared to
type – 1 driver. Driver needs to be installed separately in individual client
P a g e | 11

machines. This driver isn’t written in Java, that’s why it isn’t a portable driver.
It is a database dependent driver.

Type – 3 Driver: The Network Protocol driver uses middleware (application


server) that converts JDBC calls directly or indirectly into the vendor-specific
database protocol. Here all the database connectivity drivers are present in a
single server, hence, no need of individual client-side installation. These
drivers are fully written in Java; hence they are portable drivers. Network
support is required on client machine. It has switch facility to switch over from
one database to another database.

Type – 4 Driver: is also called Native Protocol Driver. This driver interact with
the database. It does not require any native database library, that is why it is
known as Thin Driver. It does not require any native library and middleware
server, so no client-side or server-side installation.

d. MVC Architecture:
Model View Controller or MVC is a software design pattern for developing
web applications. A Model View Controller pattern is made up of the following
three parts:
• Model: The lowest level of the pattern which is responsible for
maintaining data.
• View: This is responsible for displaying all or a portion of the data to
the user.
• Controller: Software code that controls the interaction between the
Model and View.

The Model is responsible for managing the data of the application. It responds
to the request from the view and it also responds to instructions from the
controller update itself.

The View means presentation of data in a particular format, triggered by a


controller’s decision to present the data. They are script-based templating-
systems like JSP, ASP, PHP and very easy to integrate with AJAX technology.

The Controller is responsible for responding to the user input and perform
interactions on the data model objects. The controller receives the input, it
validates the input and then performs the business operation that modifies
the state of the data model.
P a g e | 12

9. What is CSS?
Ans: Cascading Style Sheets, fondly referred to as CSS, is a simple design language
intended to simplify the process of making web pages presentable.
CSS handles the look and feel part of a web page.
Using CSS, you can control the color of the text, the style of fonts, the spacing
between paragraphs, how columns are sized and laid out, what background images
or colors are used, layout designs, and variations in display for different devices and
screen sizes as well as a variety of other effects.

Benefits of CSS:
• Improves website presentation
• Makes updates easier and smoother
• Helps web pages load faster.

10. Provide coding example for external, embedded, imported and inline style of
CSS.
Ans:
There are three type of CSS which are given below:
• Inline CSS
• Internal CSS or Embedded CSS
• External CSS

Inline CSS: contains the CSS property in the body section attached with element is
known as inline CSS. This kind of style is specified within an HTML tag using the style
attribute.

Example:
<!DOCTYPE html>
<html>
<head>
<title>Inline CSS</title>
</head>

<body>
<p style = “color: #009900; font-size: 50px;
Font-style: italic; text-align: center;”>
HelloWorld
</p>
</html>
P a g e | 13

Internal or Embedded CSS: This can be used when a single HTML document must me
styles uniquely. The CSS rule set should be within the HTML file in the head section
i.e., the CSS is embedded within the HTML file.

Example:
<!DOCTYPE html>
<html>
<head>
<title>Internal CSS</title>
<style>
.main {
text-align: center;
}
.hello{
color: #009900;
font-size: 50px;
font-weight: bold;
}
.div-container{
font-style: bold;
font-size: 20px;
}
</style>
</head>
<body>
<div class = “main”>
<div class = “hello”>HelloWorld</div>
<div class = “div-container”>
A second div.
</div>
</div>
</body>
</html>

External CSS: contains separate CSS file which contains only style property with the
help of tag attributes (for example; class, id, heading, … etc.). CSS property written in
a separate file with .css extension and should be linked to the HTML document using
link tag. This means that for each element, style can be set only once and that will be
applied across web pages.
P a g e | 14

Example: The file given below contains CSS property. This file is saved with .css
extension. For ex: hello.css

body {
background-color: powderblue;
}

.main {
text-align: center;
}

.hello {
color: #009900;
font-size: 50px;
font-weight: bold;
}

#div-container {
font-style: bold;
font-size: 20px;
}

Below is the HTML file tag that is making use of the created external style sheet
• link tag is used to link the external style sheet with the html webpage.
• href attribute is used to specify the location of the external style sheet file.

<!DOCTYPE html>
<html>
<head>
<link rel = “stylesheet” href = “style.css”/>
</head>
<body>
<div class = “main”>
<div class = “hello”>HelloWorld</div>
<div id = “div-container”>This is a heading.</div>
</div>
</body>
</html>
P a g e | 15

11. Difference between class and id in CSS.


Ans: In CSS, class and ID selectors are used to identify various HTML elements. The
main benefit of setting class or ID is that we can present the same HTML element
differently, depending on its class or ID.

The class selector selects elements with a specific class attribute. It matches all the
HTML elements based on the contents of their class attribute. The . symbol, along
with the class name, is used to select the desired class.

The ID selector matches an element based on the value of its id attribute. In order for
the element to be selected, its ID attribute must exactly match the given value in the
selector. The # symbol and the id of the HTML element name are used to select the
desired element.

The difference between an ID and a class is that an ID is only used to identify one
single element in out HTML. IDs are only used when one element on the page should
have a particular style applied to it, However, a class can be used to identify more
than one HTML element.

12. Explain RMI Architecture with suitable diagram.


Ans: RMI stands for Remote Method Invocation. It is a mechanism that allows an
object residing in one system (JVM) to access/invoke an object running on another
JVM.

RMI is used to build distributed applications; it provides remote communication


between Java programs. It is provided in the package java.rmi

Architecture of RMI application:


In RMI application, we write two programs, a server program (resides on the server)
and a client program (resides on the client).

Inside the server program, a remote object is created and reference to that object is
made available for the client (using the registry).

The client program requests the remote objects on the server and tries to invoke its
methods.

The following diagram shows the architecture of a RMI application:


P a g e | 16

Components of this architecture:


• Transport Layer: this layer connects the client and the server. It manages the
existing connection and also sets up new connections.
• Stub: is a representation of the remote object at client. It resided in the client
system; it acts as a gateway for the client program.
• Skeleton: this is the object which resides on the server side. Stub
communicates with this skeleton to pass request to the remote object.
• RRL (Remote Reference Layer): it is the layer which manages the references
made by the clients to the remote object.

13. Explain JNI Architecture with suitable diagram.


Ans: The Java Native Interface (JNI) is the native programming interface for Java that
is part of the JDK. By writing programs using the JNI, we ensure that your code is
completely portable across all platforms.

The JNI allows Java code that runs within a Java Virtual Machine (JVM) to operate
with the applications and libraries written in other languages, such as C, C++, and
assembly. In addition, the Invocation API allows us to embed the Java Virtual
Machine into our native applicatons.

Programmers use the JNI to write native methods to handle those situations when
an application cannot be written entirely in the Java programming language.

For example, we may need to use native methods and the JNI in the following
situations:
• The standard java class library may not support the platform-dependent
features needed by the application.
• We may already have a library or application written in another programming
language and we wish to make it accessible to Java applications.
P a g e | 17

• We want to implement a small portion of time-critical code in a lower-level


programming language, such as assembly, and then we have the Java
application to call these features.

14. Explain different types of EJB beans?


Ans: There are three types of enterprise bean in Java:
• Session Bean: contains business logic that can be invoked by local, remote or
webservice client. There are two types of session beans:
o Stateful Session Bean
o Stateless Session Bean

Stateful Session Bean: performs business task with the help of a state. It
can be used to access various method calls by storing the information in an
instance variable. Some of the applications require information to be
stored across separate method calls. In a shopping site, the items chosen
by a customer must be stored as data is an example of stateful session
bean.

There are 5 important annotations used in stateful session bean:


o @Stateful
o @PostConstruct
o @PreDestroy

Stateless Session Bean: implement business logic without having a


persistent storage mechanism, such as a state or database and can used
shared data.
Stateless session been can be used in situations where information is not
required to used across call methods.
P a g e | 18

There are 3 important annotations used in stateless session bean:


o @Stateless
o @PostConstruct
o @PreDestroy

• Message Driven Bean: Like session bean, it contains the business logic but it is
invoked by passing message.

• Entity Bean: It summarizes the state that can be remained in the database, it
is deprecated. Now, it is replaced with JPA (Java Persistent API).

There are two types of entity bean:


o Bean Managed Persistence
o Container Managed Persistence

Bean Managed Persistence: In a bean managed persistence type of entity


bean, the programmer has to write the code for database calls. It persists
across multiple sessions and multiple clients.

Container Managed Persistence: are enterprise bean that persists across


database. In container managed persistence the container take care of
database calls.

15. What is JMS (Java Message Service)? Why it is important in Message Driven EJB
Beans.
Ans: A message driven bean (MDB) is a bean that contains business logic. But, it is
invoked by passing the message. So, it is like JMS Receiver.

MDB asynchronously receives the message and processes it.

A message driven bean receives message from queue or topic, so you must have the
knowledge of JMS API.

JMS (Java Message Service) is an API that provides the facility to create, send and
read messages. It provides loosely coupled, reliable and asynchronous
communication. JMS is also known as a messaging service.
Generally, user sends message to application. But, if we want to send message from
one application to another, we need to use JMS API.
P a g e | 19

Consider a scenario, one application A is running in INDIA and another application B is


running in USA. To send message from A application to B, we need to use JMS.

WebLogic JMS supports service continuity in the event of a WebLogic Server


instance failure within a cluster through the configuration of multiple physical
destinations as members of a single distributed destination set. Once configured,
your producers and consumers send and receive messages through what appears
to be a single destination.

However, WebLogic JMS actually distributes the messaging load across all the
available destination members within the distributed destination. In the event that
a member becomes unavailable due to a server failure, traffic is then redirected
toward the other available destination members in the set.

16. What is Web Service?


Ans: Web services are self-contained, modular, distributed, dynamic applications
that can be described, published, located, or invoked over the network to create
products, processes, and supply chains. These applications can be local, distributed,
or web-based. Web services are built on top of open standards such as TCP/IP, HTTP,
Java, HTML, and XML.

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)

A web service enables communication among various applications by using open


standards such as HTML, XML, WSDL, and SOAP.

A web service takes the help of:


• XML to tag the data
• SOAP to transfer a message
• WSDL to describe the availability of service.

17. Explain Service Oriented Architecture with proper diagram.


Ans: Service-Oriented Architecture (SOA) is a stage in the evolution of application
development and/or integration. It defines a way to make software components
reusable using the interfaces.
P a g e | 20

• SOA allows users to combine a large number of facilities from existing services
to form applications.
• SOA encompasses a set of design principles that structure system
development and provide means for integrating components into a coherent
and decentralized system.
• SOA-based computing packages functionalities into a set of interoperable
services, which can be integrated into different software systems belonging to
separate business domains.

There are two major roles within Service-oriented Architecture:


• Service provider: The service provider is the maintainer of the service and the
organization that makes available one or more services for others to use. To
advertise services, the provider can publish them in a registry, together with a
service contract that specifies the nature of the service, how to use it, the
requirements for the service, and the fees charged.

• Service consumer: The service consumer can locate the service metadata in
the registry and develop the required client components to bind and use the
service.

17. Design one registration page using name, gender, email, form tag.
Ans:
<!DOCTYPE html>
<html>
<head>
<h1>Registration Form</h1>
</head>
<body>
<form>
<table>
<tr>
<td>Name:</td>
<td><input type = “text” placeholder = “Enter your name:”></td>
</tr>
<tr>
<td>Gender:</td>
P a g e | 21

<td><input type = “radio” id = “gender” name = “gender” value =


“male”/>Male
<input type = “radio” id = “gender” name = “gender” value =
“female”/>Female
</td>
</tr>

<tr>
<td>Email Address:</td>
<td><input type = “mail” placeholder = “Enter your email:”></td>
</tr>
</table>
</form>
</body>
</html>

18. How do you hyperlink one web page to another using ‘href’ tag.
Ans: To make page links in an HTML page, use the <a> and </a> tags, which are the
tags used to define the links. The <a> tag indicates where the link starts and the </a>
tag indicates where it ends. Whatever text gets added inside these tags, will work as
a link. Add the URL for the link in the <a href = “” >

Example:
<!DOCTYPE html>
<html>
<body>
<h2>Click on the texts below to open the URLs</h2>
<p><a href = “https://www.google.com”>Google</a></p>
<p><a href = https://www.youtube.com>YouTube</a></p>
</body>
</html>

19. Short notes on Frameset and Frames tag in HTML.


Ans:
HTML frames are used to divide the web browser window into multiple sections
where each section can be loaded separately. A frameset tag is the collection of
frames in the browser window.

The <frameset> tag in HTML is used to define the frameset. The <frameset> element
contains one or more frame elements. It is used to specify the number of rows and
P a g e | 22

columns in frameset with their pixel of spaces. Each element can hold a separate
document.

Syntax: <frameset cols = “pixels|%|”>

<!DOCTYPE html>
<html>
<head>
</head>
<frameset cols = “20%, 50%, 30%”>
<frame name = “top” src = “red.png”/>
<frame name = “main” src = “yellow.png”/>
<frame name = “bottom” src = “blue.png”/>
<noframes>
<body> The browser you are working does not support frame.</body>
</noframes>
</frameset>
</html>

20. Design the following:


NAME ID MARKS
A 10 85
B 20 75
C 30 65

Ans:
<!DOCTYPE html>
<html>
<body>
<table border="1">
<tr>
<th>NAME</th>
<th>ID</th>
<th>MARKS</th>
</tr>
<tr>
<td>A</td>
<td>10</td>
<td>85</td>
</tr>
P a g e | 23

<tr>
<td>B</td>
<td>20</td>
<td>75</td>
</tr>
<tr>
<td>C</td>
<td>30</td>
<td>65</td>
</tr>
</table>
</body>
</html>

21. Short note on XML Parser.


Ans: XML parser is a software library or a package that provides interface for client
applications to work with XML documents. It checks for proper format of the XML
document and may also validate the XML documents. Modern day browsers have
built-in XML parsers.

Following diagram shows how XML parser interacts with XML document −

The goal of a parser is to transform XML into a readable code. To ease the process of
parsing, some commercial products are available that facilitate the breakdown of
XML document and yield more reliable results.

Some commonly used parsers are listed below:


• System.Xml.XmlDocument: This class is part of .NET library, which contains a
number of different classes related to working with XML
• Java built-in parser: The java library has its own parser. The library is designed
such that you can replace the built-in parser with an external implementation
such as Xerces from Apache or Saxon.
• Saxon: offers tools for parsing, transforming, and querying XML.
• Xerces: is implemented in Java and is developed by the famous open source
Apache Software Foundation.
P a g e | 24

There are two types of XML parsers:


• DOM
• SAX

DOM (Document Object Model): is an object which contains all the information of
an XML document. It is composed like a tree structure. The DOM parser implements
a DOM API. The API is very simple to use.

Features:
A DOM Parser creates an internal structure in memory which is a DOM document
object and the client applications get information of the original XML document by
invoking methods on this document object.

Advantages:
• It supports both read and write operations and the API is very simple to use.
• It is preferred when random access to widely separated parts of a document is
required.

Disadvantages:
• It is memory inefficient (consumes more memory because the whole XML
document needs to be loaded into memory).
• It is comparatively slower than other parsers.

SAX (Simple API for XML): A SAX Parser implements SAX API. This API is an event-
based API and less intuitive.

Features:
It does not create any internal structure.
Clients does not know what methods to call, they just overrides the methods of the
API and place its own code inside method.

Advantages:
• It is very simple and memory efficient.
• It is very fast and works for huge documents.

Disadvantages:
• It is event-based so its API is less intuitive.
• Clients never know the full information because the data is broken into pieces.

22. Short note on SOAP.


P a g e | 25

Ans: SOAP is an acronym for Simple Object Access Protocol. It is an XML-based


messaging protocol for exchanging information among computers. SOAP is an
application of the XML specification.

• SOAP is a communication protocol designed to communicate via Internet.


• SOAP can extend HTTP for XML messaging.
• SOAP provides data transport for Web services.
• SOAP can exchange complete documents or call a remote procedure.
• SOAP can be used for broadcasting a message.
• SOAP is platform- and language-independent.
• SOAP is the XML way of defining what information is sent and how.
• SOAP enables client applications to easily connect to remote services and
invoke remote methods.

SOAP message transmits some basic information:


• Information about message structure and instructions on processing it.
• Encoding instructions for application defined data types.
• Information about Remote Procedure Calls and their responses.

The message in XML format contains three parts:


• Envelope: It specifies that the XML message is a SOAP message. A SOAP
message can be defined as an XML document containing header and body
encapsulated in the envelope. The fault is within the body of the message.

• Header: This part is not mandatory. But when it is present it can provide
crucial information about the applications.

• Body: It contains the actual message that is being transmitted. Fault is


contained within the body tags.

• Fault: This section contains the status of the application and also contains
errors in the application. This section is also optional. It should not appear
more than once in a SOAP message.

Advantages of SOAP:
• SOAP is a light weight data interchange protocol because it is based on XML.
• SOAP was designed to be OS and Platform independent.
• It is built on top of HTTP which is installed in most systems.
• It is suggested by W3 consortium which is like a governing body for the web.
• SOAP is mainly used for Web Services and API.
P a g e | 26

23. Differentiate between:


a. XML and HTML
b. DOM Parser and SAX Parser
c. JavaBeans and EJB

Ans:
a. XML and HTML
XML HTML
XML stands for eXtensible Markup HTML stands for Hypertext Markup
Language Language
The main purpose is to focus on the Focusses on the appearance of the
transport of data and saving the data data. Enhances the appearance of
the text
XML is dynamic because it is used in HTML is static because its main
transport of data. function is to display the data.
It is case-sensitive. It is not case-sensitive
We can define tags as per our It has its own pre-defined tags, and it
requirement, but closing tags are is not necessary to have close tags.
mandatory.
XML is content-driven and not many HTML is presentation driven. How
formatting features are available. the text appears is of utmost
importance
Any error in the code shall not give Small errors in the code can be
the final outcome. ignored and the outcome can be
achieved.

b. DOM Parser and SAX Parser


DOM Parser XML Parser
It is called as Document Object It is called as a Simple API for XML
Model. Parsing.
It stays in a tree structure. Its an event-based parser.
DOM Parser is faster than SAX SAX Parser is slower than DOM
Parser. Parser
Best for the smaller size of files. Best for the larger size of files.
It is not good at making XML files in It is suitable for making XML files in
low memory. Java.
The internal structure can be created The internal structure can not be
by DOM Parser. created by SAX Parser.
In DOM Parser backward and In SAX Parser, backward navigation is
forward search is possible. not possible.
It can insert or delete nodes. It is read-only.
P a g e | 27

Suitable for large XML document. Suitable for efficient memory.


It loads whole XML documents in A small part of the XML file is only
memory. loaded in memory.

c. JavaBeans and EJB


JavaBeans EJB
Javabeans is a component Even though EJB is a component
technology to create universal Java technology, it neither reconstructs
components. nor enhances the original JavaBean
specification.
Beaninfo classes, property editors No perception of Beaninfo classes,
or customizers can be present in property editors or customizers is in
Javabeans. Enterprise JavaBeans and no
additional information is provided
except that described in the
deployment descriptor.
An external interface called a A deployment descriptor is given in
properties interface is given in Enterprise JavaBeans to interpret
JavaBeans, that allows a builder tool the functionality to an external
to describes the functionality of a builder tool or IDE.
bean.
There is no further category of Java Enterprise JavaBeans are
Beans. categorized into two types – session
beans and entity beans.
JavaBeans have not any definite EJBs may be transactional and
support exists for transactions. transactional support is provided by
the EJB servers.

24. What do you mean by JDBC?


Ans: JDBC is an API(Application programming interface) used in java programming to
interact with databases. The classes and interfaces of JDBC allow the application to
send requests made by users to the specified database.

It provides the language with java database connectivity standards. It is used to write
programs required to access databases. JDBC, along with the database driver, can
access databases and spreadsheets. The enterprise data stored in a relational
database(RDB) can be accessed with the help of JDBC APIs.

Components of JDBC:
There are generally four main components of JDBC through which it can interact with
a database.
P a g e | 28

1. JDBC API: It provides various methods and interfaces for easy communication with
the database. It provides two packages as follows, which contain the java SE and Java
EE platforms to exhibit WORA(write once run anywhere) capabilities.

java.sql.*;
It also provides a standard to connect a database to a client application.

2. JDBC Driver manager: It loads a database-specific driver in an application to


establish a connection with a database. It is used to make a database-specific call to
the database to process the user request.

3. JDBC Test suite: It is used to test the operation(such as insertion, deletion,


updation) being performed by JDBC Drivers.

4. JDBC-ODBC Bridge Drivers: It connects database drivers to the database. This


bridge translates the JDBC method call to the ODBC function call. It makes use of the
sun.jdbc.odbc package which includes a native library to access ODBC characteristics.

Architecture of JDBC:

• Application: It is a java applet or a servlet that communicates with a data


source.
• The JDBC API: The JDBC API allows Java programs to execute SQL statements
and retrieve results. Some of the important classes and interfaces defined in
JDBC API are as follows:
• DriverManager: It plays an important role in the JDBC architecture. It uses
some database-specific drivers to effectively connect enterprise applications
to databases.
• JDBC drivers: To communicate with a data source through JDBC, you need a
JDBC driver that intelligently communicates with the respective data source.
P a g e | 29

25. Write a JavaScript to validate the mail id for @, .com etc.


Ans:
<html>
<body>
<script>
function validateemail()
{
var x=document.myform.email.value;
var atposition=x.indexOf("@");
var dotposition=x.lastIndexOf(".");
if (atposition<1 || dotposition<atposition+2 || dotposition+2>=x.length){
alert("Please enter a valid e-mail address \n atpostion:"+atposition+"\n
dotposition:"+dotposition);
return false;
}
}
</script>
<body>
<form name="myform" method="post"
action="http://www.javatpoint.com/javascriptpages/valid.jsp" onsubmit="return
validateemail();">
Email: <input type="text" name="email"><br/>
<input type="submit" value="register">
</form>
</body>
</html>

26. What are the needs of XML?


Ans:
• XML stands for Extensible Markup Language.
• It was designed to carry data, not to display data
• XML tags are not predefined. We define our own tags.
• XML is designed to be self-descriptive.
• XML is a W3C Recommendation.

The needs of XML are as follow:


• XML separates data from HTML
• XML simplifies data sharing
• XML simplifies data transport
• XML simplifies platform change
• XML increases data availability
• XML can be used to create new internet languages
P a g e | 30

27. What is XML Schema?


Ans: XML Schema is commonly known as XML Schema Definition (XSD). It is used to
describe and validate the structure and the content of XML data. XML schema
defines the elements, attributes and data types. Schema element supports
Namespaces. It is similar to a database schema that describes the data in a database.

The basic idea behind XML Schemas is that they describe the legitimate format that
an XML document can take.

28. What is DOM? What are the needs of DTD?


Ans: The Document Object Model (DOM) is a programming interface for HTML
(HyperText Markup Language) and XML (Extensible markup language) documents. It
defines the logical structure of documents and the way a document is accessed and
manipulated.

DOM is a way to represent the webpage in a structured hierarchical way so that it


will become easier for programmers and users to glide through the document. With
DOM, we can easily access and manipulate tags, IDs, classes, Attributes, or Elements
of HTML using commands or methods provided by the Document object. Using DOM,
the JavaScript gets access to HTML as well as CSS of the web page and can also add
behavior to the HTML elements. so basically Document Object Model is an API that
represents and interacts with HTML or XML documents.

HTML is used to structure the web pages and Javascript is used to add behavior to
our web pages. When an HTML file is loaded into the browser, the javascript can not
understand the HTML document directly. So, a corresponding document is
created(DOM). DOM is basically the representation of the same HTML document but
in a different format with the use of objects. Javascript interprets DOM easily i.e
javascript can not understand the tags(<h1>H</h1>) in HTML document but can
understand object h1 in DOM. Now, Javascript can access each of the objects (h1, p,
etc) by using different functions.

DTD:
The XML Document Type Declaration, commonly known as DTD, is a way to describe
XML language precisely. DTDs check vocabulary and validity of the structure of XML
documents against grammatical rules of appropriate XML language.

An XML DTD can be either specified inside the document, or it can be kept in a
separate document and then liked separately.
P a g e | 31

Its main purpose is to define the structure of an XML document. It contains a list of
legal elements and define the structure with the help of them.

29. Short notes on DHTML.


Ans:
DHTML stands for Dynamic Hypertext Markup language i.e., Dynamic HTML.
Dynamic HTML is not a markup or programming language but it is a term that
combines the features of various web development technologies for creating the
web pages dynamic and interactive.
The DHTML application was introduced by Microsoft with the release of the 4th
version of IE (Internet Explorer) in 1997.

Components of DHTML:
• HTML 4.0: HTML is a client-side markup language, which is a core component
of the DHTML. It defines the structure of a web page with various defined
basic elements or tags.

• CSS: CSS stands for Cascading Style Sheet, which allows the web users or
developers for controlling the style and layout of the HTML elements on the
web pages.

• JavaScript: JavaScript is a scripting language which is done on a client-side.


The various browser supports JavaScript technology. DHTML uses the
JavaScript technology for accessing, controlling, and manipulating the HTML
elements. The statements in JavaScript are the commands which tell the
browser for performing an action.

• DOM: DOM is the document object model. It is a w3c standard, which is a


standard interface of programming for HTML. It is mainly used for defining the
objects and properties of all elements in HTML.

Features:
• Its simplest and main feature is that we can create the web page dynamically.
• Dynamic Style is a feature, that allows the users to alter the font, size, color,
and content of a web page.
• It provides the facility for using the events, methods, and properties. And, also
provides the feature of code reusability.
• It also provides the feature in browsers for data binding.
P a g e | 32

• Using DHTML, users can easily create dynamic fonts for their web sites or web
pages.
• With the help of DHTML, users can easily change the tags and their properties.
• The web page functionality is enhanced because the DHTML uses low-
bandwidth effect.

Uses:
• It is used for designing the animated and interactive web pages that are
developed in real-time.
• DHTML helps users by animating the text and images in their documents.
• It allows the authors for adding the effects on their pages.
• It also allows the page authors for including the drop-down menus or rollover
buttons.
• This term is also used to create various browser-based action games.
• It is also used to add the ticker on various websites, which needs to refresh
their content automatically.

HTML (Hypertext Markup language) DHTML (Dynamic Hypertext Markup


language)
1. HTML is simply a markup language. 1. DHTML is not a language, but it is a set
of technologies of web development.
2. It is used for developing and creating 2. It is used for creating and designing the
web pages. animated and interactive web sites or
pages.
3. This markup language creates static 3. This concept creates dynamic web
web pages. pages.
4. It does not contain any server-side 4. It may contain the code of server-side
scripting code. scripting.
5. The files of HTML are stored with the 5. The files of DHTML are stored with the
.html or .htm extension in a system. .dhtm extension in a system.
6. A simple page which is created by a 6. A page which is created by a user using
user without using the scripts or styles the HTML, CSS, DOM, and JavaScript
called as an HTML page. technologies called a DHTML page.
7. This markup language does not need 7. This concept needs database
database connectivity. connectivity because it interacts with
users.

30. What is AJAX? How does it work?


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.
P a g e | 33

Ajax uses XHTML for content, CSS for presentation, along with Document Object
Model and JavaScript for dynamic content display.

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.
AJAX is a web browser technology independent of web server software.

Working of AJAX:

1. An event occurs in a web page (the page is loaded, a button is clicked)


2. An XMLHttpRequest object is created by JavaScript
3. The XMLHttpRequest object sends a request to a web server
4. The server processes the request
5. The server sends a response back to the web page
6. The response is read by JavaScript
7. Proper action (like page update) is performed by JavaScript

You might also like