Overview Of Servlets And Jsp Technology Computer Science Essay

Published: November 9, 2015 Words: 2119

JDBC is a front-end tool for connecting to a server and is similar to ODBC however, JDBC can connect only Java client and it uses ODBC for the connectivity. JDBC is essentially a low level application programming interface. It is called a low level API since any data manipulation, storage and retrieval has to be done by the program itself. Some tools that Provide a higher level of abstraction is expected shortly.

The next question is why we need JDBC, once we have ODBC on hand. We can use the ODBC to connect to all the databases and ODBC is a proven technology. Problem for doing this is ODBC gives a 'C' language API, which uses pointer extensively, since Java open JDBC to suit its needs.

Jdbc Driver Tipes

There are various types of driver, identified the sun such that each one has some unique features and facilitates a connection to the database.

JDBC drivers fit into of four categories:

The JDBC-ODBC bridge provides JDBC access via most ODBC drivers. Note that some ODBC binary code and in may cases database client code must be loaded on each client machine that uses this diver so this kind of driver is most application on a corporate network or for application server code written in Java in a 3-tier architecture.

A native-API partly-Java driver converts JDBC calls into on the client API for Oracle Sybase Informix DB2 or other DBMS. Note that, like the bridge driver this style of driver requires that some binary code be loaded on each client machine.

A net-protocol all-Java driver translates JDBC calls into a DBMS-independent net protocol which is then translated, to a DBMS protocol by a server. This net server middle aware is able to connect its all Java client to many different databases. The specific protocol used depends on the vendor. In general this is the most flexible JDBC alternative. It is likely that all vendors of this solution will provide suitable for intranet requirements for security, access through firewalls, etc. that the web imposes several vendors are adding JDBC drivers to their existing database middle aware products.

A native protocol driver

Jdbc Architecture

JDBC architecture is as follows

JDBC Driver Manager

JDBC Diver

JDBC-ODBC Bridge

Application

JDBC Driver Manager

Function of the driver manager is to find out available driver in the system and connect the application to the appropriate database, whenever a connection is requested. However, to help the driver manager identify different types of drivers, each driver should be registered with the driver manager.

JDBC Driver:

Function of the JDBC driver is to accept the SQL calls from the application and convert them into native calls to the database,. However, in this process it may take help from some other drivers or even servers, which depends on the type of JDBC driver we are using. It also is possible that the total functionally of the database server could be built into the driver itself.

JDBC - ODBC Bridge:

Sun soft provides a special JDBC Driver called JDBC-ODBC bridge which can be used to connect any existing database, that is ODBC complaint.

Servlet and JSP technology has become the technology of choice for developing online stores, interactive Web applications, and other dynamic Web sites. Why? This chapter gives a high-level overview of the reasons for its popularity. Later chapters specific details on programming techniques.

A Servlet's Job

Servlet are Java programs that run on applications servers. Acting as a middle layer between requests coming from web browsers or other HTTP clients and databases or applications on the HTTP server. Their job is to perform the following tasks.

Read the explicit data sent by the client.

The end user normally enters this data in an HTTP from on a web page. However the data could also come from an applet or a custom HTTP client program. Chapter 4 discusses how servlet read this data.

Read the implicit HTTP request data sent by the browser.

The shows a single arrow going from the client to the web server (the layer where servlets and JSP execute), but there are really two varieties of data: the explicit data that the end user enters in a from and the behind-the -scenes HTTP information. Both varieties are critical. The HTTP information includes cookies, information about media types and compression schemes the browser understands and so forth it is discussed in chapter 5.

Generate the results.

This process may require talking to a database, executing an RMI or EJB call, invoking a web service, or computing the response directly your real data may be in a relational database. Fine. But your database probably doesn't speak HTTP or return results in HTML, so the web browser can't talk directly to the database. Even if it could, for security reasons, you probably would not want it to.

The same argument applies to most other applications. You need the web middle layer to extract the incoming data from the HTTP stream, talk to the application, and embed the

result inside a document.

Send the explicit data (i.e., the document )to the client.

This document can be sent in a variety of formats including text (HTML or XML), binary (GIF images), or even a compressed format like zip that is layered on top of some other underlying format. But, HTML is by far the most common format, so an important, servlet / JSP task is to wrap the results inside of HTML.

Send the implicit HTTP response data.

The shows a single arrow going from the web middle layer (the servlet or JSP page) to the client. But there are really two varieties of data sent: the document itself and the behind-the -scenes HTTP information. Again both varieties are critical to effective development. Sending HTTP response data involves telling the browser or other client what type of document is being returned (e.g., HTTP), setting cookies and caching parameters, and other such tasks.

Features of JSP

JSP provides an attractive alternative to other dynamic scripting language by offering the following features:

Platform independence:

The use of adds versatility to a web application by enabling its execution on any computer.

Enhanced performance:

The compilation process in JSP produces faster results or output.

Separation of logic from display:

The use of JSP permits the HTML-specific static content and a mixture of HTML, Java, and JSP-specific dynamic content to be placed in separate fillies.

Ease of administration

The use of JSP eliminates the need for high-level technical expertise, thereby helping web developers, content creators, and content managers to work together and develop Java-based applications in less time and with less effort.

Ease of use:

All JSP applications run on major web server and operating systems, including Microsoft IIS, Netscape enterprise server, I Planet web server, and apache web server. These applications are available on Windows NT, windows 2000, and solaris7.

Competing Products across Platforms:

Competing products include active server pages (ASP), hypertext pre processor(PKP) and Java script.

JSP versus ASP:

ASP is the immediate competing technology from Microsoft. The dynamic content of JSP is written in Java, in contrast to that of ASP, which is written using an ASP-specific language, such as VBScript. As a result, complex applications can use the power of Java to result and embed Java components in JSP applications, second, JSP is portable to other operating systems and servers in contrast to the allegiance of ASP to windows NT/2000and IIS.

JSP versus PHP:

PHP is similar to ASP and JSP to a certain extent. PHP is a free, open-source, HTML-embedded, server-side scripting language, with basic HTML knowledge, however, a VBScript programmer can write ASP applications and a Java programmer can create JSP applications, whereas PHP requires learning an entirely new language, second by virtue if the power of Java, JSP has access to an extensive API for networking, database access, and objects distribution.

JSP Objects & its Scopes

In JSP there are two types of objects.

Implicit objects

Explicit objects

Implicit objects are automatically created.

Explicit objects are created using actions.

Whenever a request has been made for a JSP PAGE, JSP page will create two types of objects. They are:

Implicit objects

Explicit objects

Implicit objects are automatically created by the JSP web developers can use this objects for their processing.

Explicit objects are created thought actions. Scripting code is used to create these explicit objects. Every explicit object has some visible attribute. Scripting elements can access the explicit objects thought scripting-level variables.

JSP defines several scopes for JSP objects.

Objects Scopes:

JSP defines several scopes for objects. Scopes are used to indicate the context in which the bean should be made available.

Four types of scopes. They are:

1. Page

2. Request

3. Application

4. Session

While process the request, the JSP page can create and /or the some Java objects.

Scopes are used to indicate the context in which the dean should be made available in JSP there are four scopes are available. They are:

Page:

It is the default scopes for all the Java objects. It is used to indicate that the objects are only available on the current page. Once the response is sent back or the request is forwarded somewhere else all the object reference, which has the page scope, will be released object that contains

Page scope is stored in the page Content object of the current page.

Request:

The request scope is used to indicate that the objects are only available for the current client request. If the request is forwarded to a resource in the same runtime, the Object is still available. Once the request is processed, all the object reference, which has the request scope, will be released. Objects that contain request scope will be released. Object references that contain request scope are stored in the request Object.

Session:

The session scope indicates that the available to all pages during the life of the current session. All references to the objects shall be released after the associated session ends. References to objects with session scope are stored in the session objects associated with the page activation.

Application:

The application scope indicates that it is available to all pages that share the same context object references which contain the application scope will be released when the runtime environment reclaims the servlet context objects references that contain the application scope are stored are stored in the application objects associated with the page activation.

Directives And Actions:

JSP elements can be directives or actions. Directives elements provide global information for the translation phase. Actions elements provide for the request-processing phase. New action can be created from the tag extension mechanism.

JSP:

Elements can be directives or actions. Directive elements are used to provide global information, which is not dependent for any specific received by the JSP page. For example directive elements can be used to include the external file inside the JSP PAGE.

Action elements provide information, which is dependent on the details of the specific request received by the JSP page.

Directive elements provide information for the compilation/translation phase.

Action can create some objects and may make available to the scripting element. Action elements follow the syntax of XML elements.

JSP contains a tag extension mechanism that enables the addition of new actions. Because of the mechanism JSP can b easily portable. Actions can be customized to provide access to the attribute values and to their body. Custom action be nested and their bodies can include scripting elements.

ODBC:

Two distinct ways to access ODBC data sources with DAO the Microsoft Jet database engine DBC direct Microsoft jet provides a broad range of functionality. It handles many of the details of establishing and managing connection, translating queries into a form acceptable to the server, and managing returned data in some cases, if you want to bypass the micro soft Jet database engine and use DAO to make calls directly to the ODBC driver manager. This functionality is available through ODBC Direct.

The following steps offer a "quick start" to accessing ODBC data:

Use the ODBC data source manager in the windows control panel to setup your ODBC data source and assign it a data

Source name (DSN)

In your Visual Basic code, set an ODBC connect string that references the data source. The connect string is used to establish a connection to the data source

Create a new table def object and set it's connect string to the value specified in step two.

Append the table to the table defs collection

Open a record-set object on the linked table. This record-set

7. Object contains data in your OBDC data source and you can manipulate it using the properties and methods of a record-set object.