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

1. a.

Design the following:


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

b. How do you hyperlink one web page to another using ‘href’ tag.
c. Write short notes on:
i. Frameset and Frames tag in HTML
ii. Design one registration page using name, gender, email, form tag
Ans:
a.
<!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>
<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>
Output:

b. 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>

Output:

c. i. 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
columns in frameset with their pixel of spaces. Each element can hold a separate
document.

Syntax: <frameset cols = "pixels|%|*">

<!DOCTYPE html>
<html>
<head>
<title>frameset attribute</title>
</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 frames.</body>
</noframes>
</frameset>
</html>

Output:

ii.
<!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>
<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>

Output:

2. What do you mean by Static and Dynamic Web Pages?


What are the advantages of dynamic pages over the static web pages?
What is CGI?
Write down the advantages of 3 tier architecture over 2 tier architecture of J2EE.

Ans:
Static Web pages are very simple. It is written in languages such as HTML, JavaScript,
CSS, 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. And
these web pages are seen through a web browser. In static web pages, Pages will
remain the same until someone changes it manually.
Dynamic Web Pages are written in languages such as CGI, AJAX, ASP, ASP.NET, etc. In
dynamic web pages, the Content of 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.

Advantages of Dynamic Web Pages over Static Web Pages:


• Better user experience
• Easier maintenance
• Easy updating
• Professional ui
• Futuristic

The Common Gateway Interface (CGI) provides the middleware between WWW
servers and external databases and information sources. The World Wide Web
Consortium (W3C) defined the Common Gateway Interface (CGI) and also defined
how a program interacts with a Hyper Text Transfer Protocol (HTTP) server.

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 process or
convention for passing data back and forth between the server and the application is
called the common gateway interface (CGI).

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.
• CGI standard is generally the most compatible with today’s browsers.

Advantages of Three Tier Architecture over Two Tier Architecture of J2EE:


J2EE Three Tier Architecture which composed of three tiers logical computing. This
helps in developing specific client-server based applications. It also helps in
development by separating the User Interface, business logic, and data storage layer.
Gives greater flexibility for development for updating specific parts of the application
without affecting the rest of the parts. This flexibility can improve overall
development and upgrading and replacing data from a specific tier without affecting
the whole system.

3. What do you mean by JDBC?


Why is it called ODBC(Open Database Connectivity)?
Explain different types of JDBC drivers.
Write down different steps to create DSN in 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.

Enterprise applications created using the JAVA EE technology need to interact with
databases to store application-specific information. So, interacting with a database
requires efficient database connectivity, which can be achieved by using the
ODBC(Open database connectivity) driver. This driver is used with JDBC to interact or
communicate with various kinds of databases such as Oracle, MS Access, Mysql, and
SQL server database.

Open Database Connectivity (ODBC) is an open standard application programming


interface (API) that allows application programmers to access any database. With the
help of ODBC statement in a program, We can access different files in a number of
different of a common database.

ODBC consists of four components, working together to enable functions. ODBC


allows programs to use SQL requests that access databases without knowing the
proprietary interfaces to the databases. ODBC handles the SQL request and converts
it into a request each database system understands.

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 4 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:
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.

• As a common driver is used in order to interact with different databases, the


data transferred through this driver is not so secured.
• The ODBC bridge driver is needed to be installed in individual client machines.
• 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 machines


• The Vendor client library needs to be installed on client machine.
• Type-2 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.
• Type-3 drivers are fully written in Java, hence they are portable drivers.
• No client side library is required because of application server that can
perform many tasks like auditing, load balancing, logging etc.
• Network support is required on client machine.
• Maintenance of Network Protocol driver becomes costly because it requires
database-specific coding to be done in the middle tier.
• Switch facility to switch over from one database to another database.

Type-4 driver:
Type-4 driver is also called native protocol driver. This driver interact directly with
database. It does not require any native database library, that is why it is also known
as Thin Driver.

• Does not require any native library and Middleware server, so no client-side
or server-side installation.
• It is fully written in Java language, hence they are portable drivers.

4. Write down the Servlet Life Cycle? What is the function of init(), service() and
destroy() method in life cycle of Servlet?
Ans:
The Servlet life cycle mainly goes through four stages:
• Loading a Servlet.
• Initializing the Servlet.
• Request handling.
• Destroying the Servlet.

Servlet life cycle can be defined as the stages through which the servlet passes from
its creation to its destruction.
The servlet life cycle consists these stages:
• Servlet is borned
• Servlet is initialized
• Servlet is ready to service
• Servlet is servicing
• Servlet is not ready to service
• Servlet is destroyed

There are three life cycle methods of a Servlet:


• init(): The Servlet.init() method is called by the Servlet container to indicate
that this Servlet instance is instantiated successfully and is about to put into
service.
• service(): The service() method of the Servlet is invoked to inform the Servlet
about the client requests.
o This method uses ServletRequest object to collect the data requested
by the client.
o This method uses ServletResponse object to generate the output
content.
• destroy(): The destroy() method runs only once during the lifetime of a Servlet
and signals the end of the Servlet instance.

5. Differentiate between:
a. PreparedStatement and prepareStatement()
b. Session and Cookies
c. GET() and POST() method
d. CGI and Servlet
e. Servlet and Applet

Ans:
a.
prepareStatement PreparedStatement()
It is used when SQL query is to be It is used when SQL query is to be
executed only once. executed multiple times.
You can not pass parameters at You can pass parameters at runtime.
runtime.
Used for CREATE, ALTER, DROP Used for the queries which are to be
statements. executed multiple times.
Performance is very low. Performance is better than Statement.
It is base interface. It extends statement interface.
Used to execute normal SQL queries. Used to execute dynamic SQL queries.
We can not use statement for We can use Preparedstatement for
reading binary data. reading binary data.
It is used for DDL statements. It is used for any SQL Query.
We can not use statement for We can use Preparedstatement for
writing binary data. writing binary data.
No binary protocol is used for Binary protocol is used for
communication. communication.

b.
Basis of Cookie Session
Comparison

Cookies are client-side files Sessions are server-side files that


that are stored on a local store user information.
Definition
computer and contain user
information.

Cookies expire after the The session ends when the user
Expiry user specified lifetime. closes the browser or logs out of the
program.

It can only store a limited It is able to store an unlimited


Data storage
amount of data. amount of information.

Cookies can only store up There is a maximum memory


to a maximum of 4 KB of restriction of 128 megabytes that a
data in a browser. script may consume at one time.
Capacity
However, we are free to maintain as
much data as we like within a
session.

It is not necessary for us to Utilizing the session start()method is


execute a function in order required before we can begin the
Function to get cookies going session.
because they are stored on
the local computer.

Cookies are used to store The data is saved in an encrypted


Data Format
information in a text file. format during sessions.

Cookies are stored on a A session can store an unlimited


Storage
limited amount of data. amount of data.

c.
HTTP GET HTTP POST
In GET method we can not send large In POST method large amount of
amount of data rather limited data is sent data can be sent because the
because the request parameter is request parameter is appended into
appended into the URL. the body.
GET request is comparatively better than POST request is comparatively less
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 secure POST request is comparatively more
because the data is exposed in the URL secure because the data is not
bar. exposed in the URL bar.
Request made through GET method are Request made through POST
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 are Request made through POST
stored in cache memory of Browser. method are not stored in cache
memory of Browser.
Data passed through GET method can be Data passed through POST method
easily stolen by attackers. can not be easily stolen by
attackers.
In GET method only ASCII characters are In POST method all types of data is
allowed. allowed.

d.
Basis Servlet CGI
Approach It is thread based i.e. for It is process-based i.e. for every
every new request new new request new process is
thread is created. created.
Language The codes are written in The codes are written any
Used JAVA programming programming language.
language.
Object- Since codes are written in Since codes are written in any
Oriented Java, it is object oriented language, all the languages are not
and the user will get the object-oriented thread-based. So,
benefits of OOPs the user will not get the benefits of
OOPs
Portability It is portable. It is not portable.
Server It can use any of the web- It can use the web-server that
Independent server. supports it.
Data Sharing Data sharing is possible. Data sharing is not possible.
Link It links directly to the It does not link the web server
server. directly to the server.
HTTP server It can read and set HTTP It can neither read nor set HTTP
servers. servers.
Speed Its can speed is slower. It can speed is faster.
Platform It can be Platform It can be not Platform dependent.
dependency dependent

e.
Sr. Key Applets Servlets
No.

Execution Applets are executed on Servlets on other hand


client-side i.e applet runs executed on the server-side i.e
1
within a Web browser on servlet runs on the web Page
the client machine. on server.

Parent Parent package of Applet Parent package of Servlet


2 packages includes java.applet.* and includes javax.servlet.* and
java.awt.* java.servlet.http.*

Methods Important methods of Lifecycle methods of servlet


applet includes init(), are init( ), service( ), and
3
stop(), paint(), start(), destroy( ).
destroy().

User For the execution of the No such interface is required


interface applet, a user interface is for the execution of servlet.
4
required such as AWT or
swing.

Required The applet requires user On the other hand, Servlets


Bandwidth interface on the client are executed on the servers
5
machine for execution so it and hence require less
requires more bandwidth. bandwidth.

Secure Applets are more prone to Servlets are more secure as


6 risk as execution is on the execution is under server
client machine. security.

6. Write short notes on any one:


a. J2EE architecture
b. WWW
c. JDBC Drivers
d. MVC Architecture
e. CGI Architecture

Ans:
a.
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 you run multiple applications on a single computer. Developers can use different
J2EE application servers to run applications built with J2EE APIs.

Benefits of J2EE:
• Portability: If you 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.
The World Wide Web is abbreviated as WWW and is commonly known as the web.
The WWW was initiated by CERN (European library for Nuclear Research) in 1989.

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 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. refer Q 3.
d.
Model View Controller or MVC as it is popularly called, 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 interactions between the Model
and View.

MVC is popular as it isolates the application logic from the user interface layer and
supports separation of concerns. Here the Controller receives all requests for the
application and then works with the Model to prepare any data needed by the View.
The View then uses the data prepared by the Controller to generate a final
presentable response.

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 to
update itself.

The View: It 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.

e.
The Common Gateway Interface (CGI) provides the middleware between WWW
servers and external databases and information sources. The World Wide Web
Consortium (W3C) defined the Common Gateway Interface (CGI) and also defined
how a program interacts with a Hyper Text Transfer Protocol (HTTP) server. 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 process or
convention for passing data back and forth between the server and the application is
called the common gateway interface (CGI).

Features of CGI:
• It is a very well defined and 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.
• CGI is the best method to create a counter because it is currently the quickest
• CGI standard is generally the most compatible with today’s browsers

Advantages of CGI:
• The advanced tasks are currently a lot easier to perform in CGI than in Java.
• It is always easier to use the code already written than to write your own.
• CGI specifies that the programs can be written in any language, and on any
platform, as long as they conform to the specification.
• CGI-based counters and CGI code to perform simple tasks are available in
plenty.

Disadvantages of CGI:
• In Common Gateway Interface each page load incurs overhead by having to
load the programs into memory.
• Generally, data cannot be easily cached in memory between page loads.
• There is a huge existing code base, much of it in Perl.
• CGI uses up a lot of processing time.

7. What is CSS? Why is it important in web design?


Provide coding example for external, embedded, imported and inline style of CSS?
What is the difference between class selector and id selector in CSS?

Ans:
CSS stands for Cascading Style Sheets. It is the coding language that gives a website
its look and layout. Along with HTML, CSS is fundamental to web design. Without it,
websites would still be plain text on white backgrounds.

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

In CSS, class and ID selectors are used to identify various HTML elements. The main
benefit of setting class or ID is that you 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 value given 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 our 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.

You might also like