Vous êtes sur la page 1sur 4

1

What is XSQL Servlet?


The XSQL Servlet is a tool that processes SQL queries and outputs the result set as XML. This processor is implemented as a Java Servlet and takes an XML file containing embedded SQL queries as input. In addition, XSQL allows you to transform the generated XML document into another XML document, HTML, or text formats as needed. It is a Servlet that lets you create and use XSQL pages as clients. These pages are written in XML with embedded SQL queries and other data manipulation language (DML) statements. In addition, you can use action handlers to provide more functionality than SQL, such as writing the XML data to a file. An action handler is an application that allows you to call a Java class from within an XSQL page. There are predefined action handlers that can talk directly to the database or to Business Components for Java (BC4J), and you can create your own. An XSQL Servlet application has these logical layers:

Client - XSQL pages take care of querying and getting data by using XML with embedded SQL. To present the data, you need to convert the XML data to another form, such as HTML, wireless markup language (WML), and so on. You can write XSL style sheets to convert XML to any of these languages. XSQL Servlet in a Web Server - The servlet uses the XML SQL Utility to talk to a database. Business Logic Tier - You can optionally use a Business Components for Java tier to access and modify data. Database - You can use any database supporting JDBC 2.0 drivers.

XSQL Servlet Clients JDeveloper provides support for XSQL Servlet with these features:

Provides XSQL tags on the Component Palette Lets you automatically create XSQL pages Includes XSQL libraries Provides XSQLConfig.xml on the classpath; you can modify it as needed Provides business component action handler tags so XSQL pages can use a business logic tier to access data

How Data Transfer Take Place Between Client and Servlets?


Here is the way it goes from client to Servlet: 1. The user enters a URL through a browser, which is interpreted and passed to the XSQL Servlet through a Java Web server. The URL contains the name of the

2 target XSQL file (.xsql) and, optionally, parameters such as values and an XSL stylesheet name. Or, the user can invoke the XSQL Servlet from the command line, bypassing the browser and Java Web server. 2. The servlet passes the XSQL file to the XML parser for Java, which parses the XML and creates an API for accessing the XML contents. 3. The page processor component of the Servlet uses the API to retrieve the XML parameters and SQL statements (found between the <xsql:query> and </xsql:query> tags). The page processor also passes any XSL processing statements to the XSLT processor. 4. The page processor then constructs a database DOM by sending the SQL queries to the underlying Oracle8i database, which returns the query results. The results are embedded in the XML file in the same location as the original <xsql:query> tags. 5. If desired, the query results and any other XML data are transformed by the XSLT processor using a specified XSL stylesheet. The data can be transformed into HTML or any other format defined by the stylesheet. The XSLT processor can selectively apply different stylesheets based on the type of client that made the original URL request. This HTTP_USER_AGENT information is obtained from the client through an HTTP request. 6. The XSLT processor passes the completed document back to the client browser for presentation to the user. How Can You Use XSQL Servlets? XSQL Servlets offer a simple and productive way to get XML in and out of the database. Using simple scripts developers can:

Generate simple or complex XML documents Apply XSL style sheets to generate any text format Parse XML documents and store the data in the database Create complete dynamic web applications without programming a single line of code

3 For example, a file such as emp.xsql: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="emp.xsl"?> <FAQ xmlns:xsql="urn:oracle-xsql" connection = "scott"> <xsql:query doc-element="EMPLOYEES" row-element="EMP"> select e.ename, e.sal, d.dname as department from dept d, emp e where d.deptno = e.deptno </xsql:query> </FAQ> Generates the following SQL: <EMPLOYEES> <EMP> <ENAME>Scott</ENAME> <SAL>1000</SAL> <DEPARTMENT>Boston</DEPARTMENT> </EMP> <EMP> ... </EMP> </EMPLOYEES> With JDeveloper, you can easily develop and execute XSQL files. The built-in web server and your default web browser will be used to display the resulting pages.

4 Difference Between HTML and XML Document Representation HTML HTML stands for Hyper Text Markup Language. 2. Hyper Text Markup Language (HTML) is a markup language designed for the creation of web pages with hypertext and other information to be displayed in a web browser. 3. HTML is not a strict language that is it doesnt show any errors even when the syntax is wrong. 4. HTML doesn't use parser to display. 5. HTML is used to structure information denoting certain text as headings, paragraphs, lists and so on and can be used to describe, to some degree, the appearance and semantics of a document. 6. HTML is preferred to text display and formatting. 7. HTML is for all internet browsers. 8. HTML is just for display. XML 1. XML stands for Extensible Markup language. 2. Extensible Markup Language (XML) is a W3C-recommended general-purpose markup language for creating special-purpose markup languages, capable of describing many different kinds of data. 3. XML is a strict language that is it gives error when syntax is wrong. 4. XML uses parser to display. 5. XML is a way of describing data and an XML file can contain the data too, as in database. It is a simplified subset of Standard Generalized Markup Language (SGML). Its primary purpose is to facilitate the sharing of data across different systems, particularly systems connected via the Internet. 6. XML meant for data storage and structure. 7. XML for all devices(like PDA, Palm device etc) 8. XML can contain information and data that can be used by the programming language.

Vous aimerez peut-être aussi