Drivers in Java and JSP servlet

Classified in Other subjects

Written at on English with a size of 8.8 KB.

 

Types of controllers.
There are four bridges different driver or JDBC driver JDBC specification defined by Sun.
· Bridge 1. Drivers using the system such as a gateway or bridge. One example is the JDBC-ODBC. Not the best solution because in many cases it is necessary to install specific software on the client besides being slow access to the database.
· Bridge 2. This type of controller is called native API, that is, the driver contains Java code in which calls are made to the native methods of the database in C or C + + made in access to the database. Sometimes it is necessary to install client software to use this type of controllers.
· Bridge 3. JDBC drivers or drivers of this type are reported with an intermediate application server using sockets that move the client program requests a driver specific API. This type of driver has the advantage of not using any software on the client.
· Bridge 4. Drivers or driver of this type use network protocols that are included in the DBMS (Database Management System Data), and therefore the drivers communicate directly with the database, also using Java sockets. It is the best because this 4drivers written entirely in Java. Most of these drivers are provided by the manufacturer of your DBMS.
The method createStatement () creates an open channel through which to run queries.

executeQuery (). This method returns a ResultSet object, which can be used to access each of the returned records:
What do you need to run a servlet (also a JSP)
1. - A program for HTTP Web server. They may be the most used or popular as the Apache HTTP server, or IIS that comes with the operating system Windows NT 4.0 or Windows 2000 Server, or even in the professional version of Windows XP.
2. Servers that support servlets

3.-servlet classes packages:
javax.servlet
javax.servlet.http
a web application is a collection of servlets, JSPs, Java classes, description files the application, documents, static HTML, XHTML, images, etc.. and other resources that can be packaged and executed on different servers from different vendors. That is, a web application could be defined coma the web tier of any application.
The container is that which contains or houses a web application and is only the directory structure in which are placed all the files needed for execution of the application site.

A JSP is going through stages of evolution of three steps in your code:
JSP source code. It is written by the programmer or JSP developer. This in a text file with a. Jsp and consists of a mixture of HTML, Java language instructions, JSP directives and actions that describe how to build a Web page to respond to a request by the client.
Java source code. The JSP container translates the JSP source code to source code of a Java servlet equivalent. This source code is stored in a workspace and may be useful in the debugging process.
Compiled Java class. As with any other Java program, the generated servlet is compiled into byte code (bytecode), resulting in a file. Class that is ready to be loaded and executed by the server.
There are three types of JSP elements:
· Items scripts (scripts) that include
expressions and statements scriplets.
· Directives.
· Actions
Declarations.
A statement notifies the Java interpreter that are to define new variables or methods in the generated class file. The statements contain instructions or statements in Java with the following syntax:
<%! sentence; [judgments; ... ]%>
Scriptlets.
A scriptlet is a set of instructions or statements of Java included in an HTML page. These instructions are different from the HTML because the markers are placed between <% and%> for the JSP interpreter knows to process all the code that is within those tags. Its syntax is:
<% Case, [judgments; ...]%>
Request object.
It is an instance of javax.servlet.ServletRequest and contains information of data sent to the server via a web page. For example, the getParameter () method of request object contains values sent through a form or a URL. Thus we can recover the value or contents of the fields in a form on a website, example:
<%
String name = request.getParameter ( "name");
%>
What is a Flow?
A stream is a communication system implemented in the java.io package designed to store and retrieve information in each of the various storage devices.
The standard flow
Java like any other programming language has its own set methods that allow you to capture information on inflows and outflows send by standard devices.
The standard streams are:
· Input Data Flow:
oSe System.in done by class and often receive data from the keyboard
oUtiliza the method read () to get read keyboard character
· Output Data Flow:
oSe done by System.out class and often sends the data to screen
oUtiliza the method print () and println () to output to screen
· Data Flow error
oSe done by System.err class
onos assure that the output is redirected to the monitor to send error messages to the user
Streams that offers java.io
Java provides two abstract classes to manage the flow of data from remote computers or files and are java.io.InputStream java.io.OutputStream and then present the class hierarchy of these classes
Flows file access
Whether reading or writing to a file, these flows are handled with file access. In Java we have the FileInputStream class, with the methods needed to open and interact with a communication channel to an input file for our application, and classFileOutputStream for the case of an output file.
The FileInputStream and FileOutputStream classes are in one of its builders as a parameter the name of the file to read or write. There are two variants: one that receives an object of type File and one that receives an object of type FileDescriptor. In the next section we will see the first alternative as the File class is used for this purpose.
The File class
In the case of the File class that is used to encapsulate the interaction of our programs with the file system. Using the File class we do not just read the file contents, as with the FileInputStream class, but we can obtain additional information such as file size, its type, its creation date, access permissions that we have with him etc..
The classDataOutputStream, is an extension of the OutputStream class, and adds to it the possibility of writing data "complex" in an output stream. When we speak of data as "complex" actually we refer to primitive data type, but not restricted to only bytes and byte arrays, as in the case of OutputStream.
By DataOutputStream class can write data of type int, float, double, char, etc.. We can also write some objects, like String data in a large number of formats.
The class DataInputStream
If we can write formatted data then we can read comfortably. This feature is possible because we have the class DataInputStream.
The class DataInputStreamis designed to read data generated by a DataOutputStream object. The specification of this class ensures that any file written by a DataOutputStream, on any platform and operating system, will be readable by a DataInputStream correctly, without having to worry that if the machines are little-endian "or" big-endian " .

Entradas relacionadas: