Sei sulla pagina 1di 35

PART - A 1. WHAT IS THE USE OF XML NAMESPACE? XML allows document authors to create custom elements.

. This extensibility can result in naming collisions (i.e. different elements that have the same name) among elements in an XML document. An XML namespace is a collection of element and attribute names. Each namespace has a unique name that provides a means for document authors to unambiguously refer to elements with the same name (i.e. prevent collisions).

2. WHAT ARE THE USES OF XML? CML Chemical Markup Language for chemical equations MML - Mathematical Markup Language for Mathematical equations and derivations. Used in bio medical line.

3. WHAT IS THE USE OF XML? Extensible Markup Language, derived from SGML (Standard Generalized Markup Language. XML is widely supported open technology (i.e. non-proprietary) for electronic data exchange and storage. XML is actually a language used to create other markup languages to describe data in a structured manner. XML documents contain only data, not formatting instructions, so applications that process XML documents must decide how to manipulate or display the documents data.

4. WHAT DO YOU MEAN BY DTD IN XML? DTD means Document Type Definition.

DTD file is similar to CSS file, because DTD also contains only styles. DTD contains various styles which are to be applied in XML document . Like .CSS file .DTD file also should be linked with XML program. Styles in XML program should be save with .xsl (Xml Style Sheet Language) extension.

5. Define XML. XML is a meta-markup language that provides a format for describing structured data. This facilitates more structured declarations of content and more meaningful search results across multiple platforms.

6. Define DTD. A DTD is a set of rules that specifies how to use XML markup. It contains specifications for each element, including what the element\'s attributes are, what values the attributes can take on and what elements can be contained in others.

7. What are the XML rules for distinguishing between the content of a document and the XML markup element? 1.The start of XML markup elements is identified by either the less than symbol (<) or the ampersand (&) character 2.Three other characters, the greater than symbol (>), the apostrophe or single quote () and the double quotation marks () are used by XML for markup. 3.To use these special characters as content within your document, you must use the corresponding general XML entity.

8. What are the different XSLT elements?

Stylesheet Value-of For-each Sort Text 9. What is VoiceXML? VoiceXML is an emerging standard for speech-enabled applications.Its XML syntax defines elements to control a sequence of interaction dialogs between a user and an implementation platform. VoiceXML uses XML text to drive voice dialogs.

10. What is XQuery? XQuery is a W3C initiative to define a standard set of constructs for querying and searching XML documents. XQuery brings database query processing to XML.

11. What is XForm? XForm is an XML approach that overcomes the limitations of HTML forms. XForm includes a variety of buttons, scrollbars and menus. It generates XML form data as output. XForm\'s model has the capability to work with the variety of user interfaces.

12. What is XPath? Xpath is used to navigate XML tree structures. XPath gets its name from its use of a path notation to navigate through the hierarchical tree structure of an XML document. It is an important XML technology due to its role in providing a common syntax and semantics for functionality in both XSLT and XPointer. 13. what are complex types? complex types are an important aspects of xml schema that allow application developers to define application-specific datatypes that can be checked by programs that check XML

document for validity. XML schema divides complex types into two categories: those with simple content & those with complex content.

14. What all are the presentation technologies? CSS - cascading syle sheets XSL - provides users with ability to describe how xml data & document are to be formated. Xforms - it is a GUI toolkit for creating user interfaces & delivering the results in XML. Xhtml - it is used yo replace HTML with more flexable approach to display webcontent. VoiceXML - it is an emerging standard for speech enabled application.

15. what are all the Transformation techniques? XSLT - it is an XML- based languages used to transform XML documents into others format such as HTML for web display. XLINK - highlighting that element or taking the user directly to that point in the document. XPATH - xpath gets its name from its use of a payh notation to navigate through the hierarchical tree structure of an XML document XQUERY - it is w3c initiative to define a standard set of constructs for querying & searching XML document.

16. .Explain any two XForm implementations? X-Smiles - it is a java based XML browser.it implements a large part of X-forms & uses X-form together with XSL-FO on user interface side. Mozquito Xforms preview - is an XML based Web developement s/w that implements Xforms & gives current Web browser the ability to send,receive & process XML document.

17. what are the Importants of SAX? SAX is an event driven.

SAX supports processing pipelines. SAX requires programmers to maintain state. 18. What is metadata? Literally data about data. XML element and attribute names are considered metadata in that they may be used to describe the data contained in a document. Metadata isnt needed but it certainly helps.

19. What is DTD? How is it different from XML? DTD stands for Document Type Definition DTD is a description of the structure & the elements and attributes that define a class of XML document. DTD can be declared both internally in a XML document and as an external reference. DTD Xml Schema Dtd is used to define the structure of an xml document. Xml schema is used to define the structure of an xml document. Data type for elements limited to text. 2. Numerous predefined data types available. Complex data types cannot be defined. 3. Ability to define complex type that map to application data structure. Dtd document is stored as filename.dtd 4.Xml schema document is stored as filename.xml

20. What is XML? How it is different from HTML? Xml is the text based make up language that stores the data in a structured format using meaningful tags. It allows computers to store and exchange data in a format that can be interpreted by any other computer with different hardware or software specification. XML HTML

.xml stands for Extensible markup language HTML stands for Hyper Text Mark Up Language.2.Several languages are derived from xml & wml HTML can be derived from xml. Xml uses indefinite, user defined, meaningful set of tags which can be used to include XML data in the webpage. HTML uses a fixed set of tags which can be used to specify the appearance of the webpage.

21. Define Directives. Directives are JSP elements that provide global information about an entire JSP page,

22. Write down the various attributes for the page directives in JSP. The page directive defines information that will be globally available for that Java Server Page, language extends import session buffer contenttype

23. What is a Hidden Comment? A comments that documents the JSP page but is not sent to the client. The JSP engine ignores a hidden comment, and does not process any code within hidden comment tags. A hidden comment is not sent to the client, either in the displayed JSP page or the HTML page source. The hidden comment is useful when you want to hide or \"comment out\" part of your JSP page. 24. You can use any characters in the body of the comment except the closing --%> combination. If you need to use --%> in your comment, you can escape it by typing --%\\>. JSPSyntax <%-- comment --%> Examples <%@ page language=\"java\" %> <html> <head><title>A Hidden Comment </title></head> <body> <%-- This comment will not be visible to the colent in the page source --%> </body> </html>

25. What is a Expression? An expression tag contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. Because the value of an expression is converted to a String, you can use an expression within text in a JSP file. Like <%= someexpression %> <%= (new java.util.Date()).toLocaleString() %> You cannot use a semicolon to end an expression

26. What is a Declaration? A declaration declares one or more variables or methods for use later in the JSP source file. A declaration must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as they are separated by semicolons. The declaration must be valid in the scripting language used in the JSP file.

<%! somedeclarations %> <%! int i = 0; %> <%! int a, b, c; %>

27. What is a Scriptlet? A scriptlet can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language.Within scriptlet tags, you can 1.Declare variables or methods to use later in the file (see also Declaration).

2.Write expressions valid in the page scripting language (see also Expression).

3.Use any of the JSP implicit objects or any object declared with a <jsp:useBean> tag. You must write plain text, HTML-encoded text, or other JSP tags outside the scriptlet. Scriptlets are executed at request time, when the JSP engine processes the client request. If the scriptlet produces output, the output is stored in the out object, from which you can display it.

28. What are implicit objects? List them?

Certain objects that are available for the use in JSP documents without being declared first. These objects are parsed by the JSP engine and inserted into the generated servlet. The implicit objects re listed below request response pageContext session application out config page exception

29. Difference between forward and sendRedirect? When you invoke a forward request, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request. This process occurs completly with in the web container. When a sendRedirtect method is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completly new request any object that are stored as request attributes before the redirect occurs will be lost. This extra round trip a redirect is slower than forward.

30. What are the different scope valiues for the <jsp:useBean>? The different scope values for <jsp:useBean> are page request

session application 31. Explain the life-cycle mehtods in JSP? THe generated servlet class for a JSP page implements the HttpJspPage interface of the javax.servlet.jsp package. Hte HttpJspPage interface extends the JspPage interface which inturn extends the Servlet interface of the javax.servlet package. the generated servlet class thus implements all the methods of the these three interfaces. The JspPage interface declares only two mehtods - jspInit() and jspDestroy() that must be implemented by all JSP pages regardless of the client-server protocol. However the JSP specification has provided the HttpJspPage interfaec specifically for the JSp pages serving HTTP requests. This interface declares one method _jspService().

The jspInit()- The container calls the jspInit() to initialize te servlet instance.It is called before any other method, and is called only once for a servlet instance.

The _jspservice()- The container calls the _jspservice() for each request, passing it the request and the response objects. The jspDestroy()- The container calls this when it decides take the instance out of service. It is the last method called n the servlet instance.

32. What is a output comment? A comment that is sent to the client in the viewable page source.The JSP engine handles an output comment as uninterpreted HTML text, returning the comment in the HTML output sent to the client. You can see the comment by viewing the page source from your Web browser. JSP Syntax <!-- comment [ <%= expression %> ] --> Example 1 <!-- This is a commnet sent to client on

<%= (new java.util.Date()).toLocaleString() %>--> Displays in the page source: <!-- This is a commnet sent to client on January 24, 2004 -->

33. Define ASP. Active Server Pages (ASP) is a server-side scripting technology that can be used to create dynamic and interactive web applications.

34. What are the ASP objects? 1.Application -It manages your web application. 2.Session -It manages and tracks individual user sessions. 3.Server -It controls behavior of your web server 4.Response -It transmits information from the web server to web browser 5.Request -It retrieves information from the browser for processing at the server.

35. What is global.asa file? The global.asa file is a Active Server Application file you can track and manage the application and session events, variables and objects. When you start the application the server will load the global.asa file into memory.

36. Define response object and list its methods. The response object transmits information from the web server to browser.

Methods are: 1.Write 2.BinaryWrite 3.Redirect 4.AppendToLog 5.AddHeader 6.Clear 7.Flush

37. Define JSP. Java Server Pages (JSP) are simple technology used to generate dynamic HTML on the server side.

38. Define Directives. Directives are JSP elements that provide global information about an entire JSP page,

39. Write down the various attributes for the page directives in JSP. The page directive defines information that will be globally available for that Java Server Page, 1. language 2. extends 3. import

4. session 5. buffer 6. contenttype

40. Define XML. XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined. You must define your own tags XML is designed to be self-descriptive XML is a W3C Recommendation

41. .Define DTD. A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements and attributes. A DTD can be declared inline inside an XML document, or as an external reference.

1. What is SOAP? (Simple Object Access Protocol) SOAP is an XML based protocol that allows applications to easily over the internet using XML documents called AOAP message. A SOAP message contains an envelope, which is a structure that describes a method call. A SOAP messages body contains either a request or a response.

A request messages body contains a Remote Procedure Call (RPC), which is a request for another machine to perform task. The RPC specifies the method to be invoked and any parameters the method takes. The application sends the SOAP message via an HTTP POST. A SOAP response message is an HTTP response document that contains the results from the methods call (e.g. return values, error messages.)

2. WHAT IS THE USE OF WEB SERVICES? Web services encompass a set of related standards that can enable two computer The data is passed back and forth using standard protocols such as HTTP, the same protocol used to transfer ordinary web pages. Web services operate using open, text-based standards that enable components written in different languages and on different platforms to communicate. They are ready to use pieces of software on the Internet. XML, SOAP, Web Services Description Language (WSDL) and Universal Description, Discovery and Integration (UDDI) are the standards on which web services rely. UDDI is another XML based format that enables developers and business to publish and locate Web services on a network.

3. What do you mean by JDBC? JDBC Part of the Java Development Kit which defines an application-programming interface for Java for standard SQL access to databases from Java programs.

4. Define ODBC. It is a standard for accessing different database systems. There are interfaces for Visual Basic, Visual C++, SQL and the ODBC driver pack contains drivers for the Access, Paradox, dBase, Text, Excel and Retrieve databases. 5. What are the advantages of web services?

Reusable application-components. There are things applications need very often. So why make these over and over again? Web services can offer application-components like: currency conversion, weather reports, or even language translation as services. Connect existing software. Web services can help to solve the interoperability problem by giving different applications a way to link their data. With Web services you can exchange data between different applications and different platforms.

6. List out some web service technologies? XML, SOAP, WSDL

7. What is XML ? Extensible markup language. It offer a standard, flexible and inherently extensible data format, XML significantly reduces the burden of deploying the many technologies needed to ensure the success of Web services.

8. What is SOAP? Service Oriented Architecture Protocol. It provides a standard, extensible, composable framework for packaging and exchanging XML messages. In the context of this architecture, SOAP also provides a convenient mechanism for referencing capabilities (typically by use of headers).

9. What is WSDL? Web Services Description Language WSDL is a language for describing Web services. WSDL describes Web services starting with the messages that are exchanged between the requester and provider agents. The messages themselves are described abstractly and then bound to a concrete network protocol and message format. 10. What are Web Services? Web services are application components Web services communicate using open protocols Web services are self-contained and self-describing Web services can be discovered using UDDI Web services can be used by other applications XML is the basis for Web services 11.How Does web services Work? The basic Web services platform is XML + HTTP. XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions. The HTTP protocol is the most used Internet protocol.

12. WHAT ARE THE VARIOUS Web services platform elements? SOAP (Simple Object Access Protocol) UDDI (Universal Description, Discovery and Integration) WSDL (Web Services Description Language)

13. WHAT ARE THE TYPES OF Web SERVICES AND ITS USES? Reusable application-components. There are things applications need very often. So why make these over and over again? Web services can offer application-components like: currency conversion, weather reports, or even language translation as services. Connect existing software. Web services can help to solve the interoperability problem by giving different applications a way to link their data. With Web services you can exchange data between different applications and different platforms.

14. WRITE SHORT NOTES ON Web Services Technologies? Web service architecture involves many layered and interrelated technologies. There are many ways to visualize these technologies, just as there are many ways to build and use Web services.

15. WRITE SHORT NOTES ON SOAP. SOAP 1.2 provides a standard, extensible, composable framework for packaging and exchanging XML messages. In the context of this architecture, SOAP 1.2 also provides a convenient mechanism for referencing capabilities (typically by use of headers). [SOAP 1.2 Part 1] defines an XML-based messaging framework: a processing model and an exensibility model. SOAP messages can be carried by a variety of network protocols; such as HTTP, SMTP, FTP, RMI/IIOP, or a proprietary messaging protocol.

16. DEFINE WSDL. WSDL 2.0[WSDL 2.0 Part 1] is a language for describing Web services.

WSDL describes Web services st arting with the messages that are exchanged between the requester and provider agents. The messages themselves are described abstractly and then bound to a concrete network protocol and message format.

17. Draw the architecture of UDDI.

18. WRITE SHORT NOTES ON UDDI Universal Description, Discovery, and Integration (UDDI) The directory shown in the above figure could be a UDDI registry. The UDDI registry is intended to eventually serve as a means of \"discovering\" Web Services described using WSDL . The idea is that the UDDI registry can be searched in various ways to obtain contact information and the Web Services available for various organizations. How much \"discovery\" will be used in the early days of Web Services is open to discussion. Nevertheless, even without the discovery portion, the UDDI registry is a way to keep up-to-date on the Web Services your organization currently uses. More on Universal Description, Discovery, and Integration (new window). An alternative to UDDI is the ebXML Registry (new window).

19. EXPLAIN DTD for XML Schemas XML documents are processed by applications Applications have assumptions about XML documents DTDs allow to formalize some of these constraints Part of the constraint checking must still be programmed 20. WHAT ARE Modeling DTDs.? Data models can be mapped to many different DTDs What is a good DTD? What is a bad DTD?

How does the DTD affect further processing

21. WHAT ARE THE SOAP Related Technologies? SOAP is a simple XML-based protocol to let applications exchange information over HTTP. In our SOAP tutorial, you will learn what SOAP is, and how it uses XML to exchange information between applications.

22. DEFINE SOAP structure SOAP once stood for \'Simple Object Access Protocol\' but this acronym was dropped with Version 1.2 of the standard.[1] Version 1.2 became a W3C recommendation on June 24, 2003. The acronym is sometimes confused with SOA, which stands for Service-oriented architecture; however SOAP is different from SOA.

23. What is SOAP? SOAP stands for Simple Object Access Protocol SOAP is a communication protocol SOAP is for communication between applications SOAP is a format for sending messages SOAP communicates via Internet SOAP is platform independent SOAP is language independent SOAP is based on XML SOAP is simple and extensible SOAP allows you to get around firewalls

JSP Implicit Objects


Implicit objects in jsp are the objects that are created by the container automatically and the container makes them available to the developers, the developer do not need to create them explicitly. Since these objects are created automatically by the container and are accessed using standard variables; hence, they are called implicit objects. The implicit objects are parsed by the container and inserted into the generated servlet code. They are available only within the jspService method and not in any declaration. Implicit objects are used for different purposes. Our own methods (user defined methods) can't access them as they are local to the service method and are created at the conversion time of a jsp into a servlet. But we can pass them to our own method if we wish to use them locally in those functions. There are nine implicit objects. Here is the list of all the implicit objects: Object Class application javax.servlet.ServletContext config javax.servlet.ServletConfig exception java.lang.Throwable out javax.servlet.jsp.JspWriter page java.lang.Object PageContext javax.servlet.jsp.PageContext request javax.servlet.ServletRequest response javax.servlet.ServletResponse session javax.servlet.http.HttpSession Application: These objects has an application scope. These objects are available at the widest context level, that allows to share the same information between the JSP page's servlet and any Web components with in the same application. Config: These object has a page scope and is an instance of javax.servlet.ServletConfig class. Config object allows to pass the initialization data to a JSP page's servlet. Parameters of this objects can be set in the deployment descriptor (web.xml) inside the element <jsp-file>. The method getInitParameter() is used to access the initialization parameters. Exception: This object has a page scope and is an instance of java.lang.Throwable class. This object allows the exception data to be accessed only by designated JSP "error pages." Out: This object allows us to access the servlet's output stream and has a page scope. Out object is an instance of javax.servlet.jsp.JspWriter class. It provides the output stream that enable access to the servlet's output stream. Page: This object has a page scope and is an instance of the JSP page's servlet class that processes the current request. Page object represents the current page that is used to call the methods defined by the translated servlet class. First type cast the servlet before accessing any method of the servlet through the page.

Pagecontext: PageContext has a page scope. Pagecontext is the context for the JSP page itself that provides a single API to manage the various scoped attributes. This API is extensively used if we are implementing JSP custom tag handlers. PageContext also provides access to several page attributes like including some static or dynamic resource. Request: Request object has a request scope that is used to access the HTTP request data, and also provides a context to associate the request-specific data. Request object implements javax.servlet.ServletRequest interface. It uses the getParameter() method to access the request parameter. The container passes this object to the _jspService() method. Response: This object has a page scope that allows direct access to the HTTPServletResponse class object. Response object is an instance of the classes that implements the javax.servlet.ServletResponse class. Container generates to this object and passes to the _jspService() method as a parameter. Session: Session object has a session scope that is an instance of javax.servlet.http.HttpSession class. Perhaps it is the most commonly used object to manage the state contexts. This object persist information across multiple user connection.

Implicit objects are provided by JSP itself, we dont need to define it we can simply use these objects by setting values and attributes. JSP container does all work like instantiating, defining and maintenance. JSP provide following implicit objects

1. out
out is javax.servlet.jsp.JspWriter class use for printing. Out is Output Stream use response.getWriter() to send output to client

<% %>

out.write("This is use for print output stream on client");

2. page
<% %>

page is used by java.lang.Object class. Page is instance of JSP pages Servlet.


Object page = this;

3. pageContext
pageContext instance that contains all datas information, which is associated with JSP page. This helps to access attribute and other fields object set in JSP page. pageContext is in javax.servlet.jsp.PageContext class. pageContext is to managed various scope of attribute in

shared information object. Method of pageContext are following: Method Return pageContext.findAttribute(String Name) Object pageContext.forward(String relativeURLPath) pageContext.getAttribute(String Name) pageContext.getAttributesScope(String Name) pageContext.getErrorData() pageContext.getException() pageContext.getOut() pageContext.getRequest() pageContext.getResponse() pageContext.getServletConfig() pageContext.getServletContext() pageContext.getSession() void

Object int ErrorData Exception JspWriter

Description Search for named attribute in JSP page Request,session, application scope This method is used to redirect or forward the current ServletRequest or ServletResponse to another active component Returns the object associated with name in the page scope Get the scope where a given attribute is defined Provide access to error information Get current value of the exception Object Get current value of out object

ServletRequest Get current value of request object ServletResponse Get current value of response object ServletConfig Get any initialization parameters and startup configuration for this servlet ServletContext Gets the context from the servlet's ServletConfig object HttpSession Return the current value of session object

4. request
The HttpServletRequest object that javax.servlet.http.HttpServletRequest interface is provided to access request objects in JSP. The HTTP request is send to server through request object. More example request object reference

5. response
The HttpServletResponse object that javax.servlet.http.HttpServletResponse interface is provided to send response object in JSP. The HTTP response is send to client through response object More example response object reference

6. session
Session object is used to track information about a user, session is interface and maintain by HttpSession javax.servlet.http.HttpSession. More example of session object reference

7. config
config object is related to get servlets configuration information. It is in javax.servlet.ServletConfig interface. Servlet configuration object is used to pass information of servlet to Servlet container during initialization of servlet. This is defined in web.xml file with <init-param> and method is used to get getServletConfig()
<servlet> <servlet-name>ServletName</servlet-name> <servlet-class>com.myapp.servlet.ServletName</servlet-class> <init-param> <param-name>dbUserName</param-name> <param-value>root</param-value> </init-param> </servlet>

Method use to get init param is getInitParameter() to get value inside <param-value> and getInitParameterNames() to get name of <param-name>

8. application
Application object is used to share information for all JSPs and Servlets in the application context. Application is in javax.servlet.ServletContext. More example of application object reference

9. exception
Exceptions are condition that can be caught and recovered from it. If exception is not caught it should throw on error page. Exception when throw on error page it should be isErrorPage= true at in directive page.
<%@ page errorPage="error.jsp" %> <%@ page isErrorPage="true" %>

Example of Exception Implicit object in JSP


exception.jsp
<%@ page language="java" errorPage="error.jsp" %> <html> <head> <title>Implicit Exception object</title> </head> <body>

<% String a=null; int b=Integer.parseInt(a); %> </body> </html>

error.jsp
<%@ page language="java" import="java.io.*" isErrorPage="true" <html> <head> <title>Implicit Exception Error page</title> </head> <body> The Exception is <strong><%= exception.toString() %></strong><br> Message : <strong><%=exception.getMessage()%></strong><br> </body> </html> XML METHODS %>

Methods

abort [ie] createAttribute createCDATASection (data ) createComment (comment) createDocumentFragment (data ) createElement (tagName) createEntityReference (name ) createNode [ie] (type, name, nameSpaceURI) createProcessingInstruction (target, data) createTextNode (data) getElementsByTagName (tagName) load [ie] (url) loadXML [ie] (xml_string) nodeFromID [ie] (id_string) save [ie] (objTarget)

XML Parser

A parser is a piece of program that takes a physical representation of some data and converts it into an in-memory form for the program as a whole to use. Parsers are used everywhere in software. An XML Parser is a parser that is designed to read XML and create a way for programs to use XML. There are different types, and each has its advantages. Unless a program simply and blindly copies the whole XML file as a unit, every program must implement or call on an XML parser. The main types of parsers are known by some funny names: SAX, DOM and pull. For each type, there are some excellent implementations freely available for a variety of languages, including Java, C++, C#, VB# (in fact, any .Net language), PHP, Perl, Python, Ruby and so on.

What is SAX?

SAX stands for Simple API for XML. Its main characteristic is that as it reads each unit of XML, it creates an event that the calling program can use. This allows the calling program to ignore the bits it doesn't care about, and just keep or use what it likes. The disadvantage is that the calling program must keep track of everything it might ever need. SAX is often used in certain highperformance applications or areas where the size of the XML might exceed the memory available to the running program. The design inspiration and subsequent coodination was done by Dave Megginson, who continues to maintain the SAX Project website. The SAX standard currently is at version 2.0. SAX is used everywhere in Stylus Studio. It is used for building certain representations of XML structure for the XSLT and XQuery Mappers, and also used extensively within the XML Converters. There have been many implementations of SAX parsers. The Apache project has sponsored some, including Crimson and its successor, Xerces (available in both C++ and Java.) The author of Saxon, Dr. Michael Kay, himself wrote lfred another SAX parser.

What's a DOM?

DOM stands for Document Object Model. It differs from SAX in that it builds the entire XML document representation in memory and then hands the calling program the whole chunk of memory. DOM can be very memory intensive; by the time you figure in the overhead for

managing the relationships of the nodes, you might be talking 4 to 8 the size of the original document in memory usage. There are places in Stylus Studio where a DOM is necessary. The Tree View in the XML Editor and all XSLT and XQuery processors, no matter what the brand, with two notable exceptions. Both the underlying Saxon engine and DataDirect XQuery support pull parsing, which will be covered below. The XML Pipeline deployer is very smart; it knows for each component what the optimal representation is, and will work hard to ensure that memory is conserved wherever possible by avoiding unnecessary transformations from DOM to SAX and back. Implementations include Xerces (again both in C++ and Java), and Microsoft's MSXML and System.Xml classes. DOM (currently up to level 3.0) has been widely criticized for being too complicated; it has tried to maintain the same programming interface for whatever language it is implemented in, even if it violates some of the conventions of that language. This has led to some DOM-like implementations that are more in keeping in line with the philosophy of the local language. Examples in Java include TinyTree (used only in Saxon), JDOM, DOM4J and XOM.

What's a Pull Parser?

SAX is a push parser, since it pushes events out to the calling application. Pull parsers, on the other hand, sit and wait for the application to come calling. They ask for the next available event, and the application basically loops until it runs out of XML. Pull parsers are useful in streaming applications, which are areas where either the data is too large to fit in memory, or the data is being assembled just in time for the next stage to use it. It is designed to be used with large data sources, and unlike SAX which returns every event, the pull parser can choose to skip events (or in some implementations, whole sections of the document) that it is not interested in. The converters are designed to work with both the SAX and the pull parser interfaces. In Java, the current leading contender for streaming parsers appears to be StAX, while in Microsoft's .Net platform, the System.Xml XmlReader is built right in.

StAX Streaming API for XML


The StAX pull-parser has been implemented in the Java world by a standard called JSR-173. Both Saxon and DataDirect XQuery support pull parsing. In some instances, particularly in

DataDirect's implementation, pull parsing can give a significant performance boost, but both implementations have been so highly tuned that the choice between SAX, DOM and StAX for any given application is a matter for testing. Since within Stylus Studio XML Enterprise Suite the XML Pipeline constructor knows the capabilities of each node in the pipeline, this choice is handled automatically for you.

Standards and Stylus Studio


One very important point is that each of these is an industry-recognized standard. This means that whatever you do is portable across implementations. Whether you like the SJSXP or Woodstox StAX parsers, whether you like Crimson or lfred or Xerces, the point is you have a choice. If one fails to perform for you in the way you hope, or you want to migrate from one platform to another for deployment, you are never locked in by Stylus Studio. As a division of DataDirect Technologies, we have a legacy of participation and conformance to the standards process, and we are proud of this heritage Download and Examine a copy of Stylus Studio today, and see how powerful a fully standards-compliant XML application you can design and deploy.

JSP Page Directive


JSP

JSP Introduction JSP Environment Setup JSP Tags JSP Directives JSP Page Directive JSP Directive Tag and Scriptlet tag JSP Action tags JSP Request Object JSP Implicit and Session Objects JSP Response Object JSP Architecture Working with JSP Sessions JSP Out Object JSP Application Object Home Tutorials JSP

JSP Page Directive


Author : Exforsys Inc. Published on: 28th Apr 2007

JSP Page Directive


In this JSP tutorial, you will learn about JSP page directive, attributes of the page directive along with syntax, examples and explanations. Ads

autoFlush:
autoFlush attribute is used to specify whether or not to automatically flush out the output buffer when it is full. Syntax of autoFlush attribute available for page directive is written as:

&lt;%@ page autoFlush = "true|false" %&gt;

In the above example, page and autoFlush are keywords. True or false value can be set to autoFlush attribute, by default, its value is true . This means, the buffer will be flushed automatically when it is full. When the autoflush attribute is set to false, then an exception is thrown when the output buffer gets full and results in overflow. NOTE: The user should not to set the autoflush to false when the buffer attribute is set to none.

isThreadSafe:
isThreadSafe attribute is used to set whether the generated Servlet handles multiple requests or single requests, depending on the set value of true or false. isThreadSafe attribute is used to set and ensure whether thread safety is implemented in the JSP page. Syntax of isThreadSafe attribute available for page directive is:

&lt;%@ page isThreadSafe="true|false" %&gt;

In the above statement, page and isThreadSafe are keywords. A true or false value can be set and, by default, the value is set to true. It implies that the JSP container can handle or send multiple concurrent client requests to the JSP page by starting a new thread. If the value of this attribute is set to false, then the JSP container sends client requests only one at a time to the JSP page.

info:
Programmers make use of info attribute to place the information or documentation for a page. Details such as: author, version, copyright and date are placed in this attribute. This is actually text string that is written as input text in the compiled JSP page. Syntax of info attribute available for page directive is:

&lt;%@ page info = "text" %&gt;

In the above statement, page and info are keywords. The details of documentation or information are placed inside " ". This is actually text string written as input text in the compiled JSP page.

For example:

&lt;%@ page info = "exforsys.com example,2006" %&gt;

The above text, exforsys.com example, 2006, is a text string written as text in the compiled JSP page.

errorPage:
If the programmer wants to place errors in a different page then the URL to the error page can be mentioned in this attribute as errorPage. Syntax of errorPage attribute available for page directive is as below:

&lt;%@ page errorPage = "relativeURL" %&gt;

In the above statement, page and errorPage are keywords.

For example, the user specifies the attribute errorpage is:

&lt;%@ page errorPage = "/handleerr/testerr.jsp" %&gt;

isErrorPage:
isErrorPage attribute is used to specify whether or not a JSP page displays an error page by setting the value as true or false. By default, the value is set to false, meaning that the user cannot make use of the exception object in the JSP page. If the value is set to true, then it means that the user can make use of the exception object in the JSP page. Syntax of isErrorPage attribute available for page directive is:

&lt;%@ page isErrorPage="true|false" %&gt;

In the above statement, page and isErrorPage are keywords. By default, the value is false.

age directive is used to specify a number of page specific attributes such as content type, page encoding, classes to import and buffering model etc. A translation unit can contain more than one instance of page directive, in any order, anywhere and all attributes will be applied together to the whole translation unit. However there are few exceptions. 1. pageEncoding and contentType attributes must appear at the beginning of the page. 2. An attribute must appear only once in a translation unit unless the values of the attribute are same for all occurrences, otherwise a translation error will occur. The import and pageEncoding can appear more than once in a translation unit. 3. pageEncoding attribute can appear at most once per a file otherwise a translation error will occur. Note: A JSP source file and any other files included with include directive is called the translation unit. Below is a complete list of attributes that can be used with page directive.

Attribute name language extends import

Description Specifies the scripting language used in scriptlets, expressions and declarations in the JSP page The fully qualified name of a java class, that defines the super class of the JSP pages implementation servlet

The comma separated list of class names that will be imported in resulting servlet. It is similar to java import statement Indicates that the page participates in session. If the value is true, an implicit variable named session of type javax.servlet.HttpSession is available and references current session. If the value is false than implicit variable session unavailable and any attempt to use it within the body of the page will result in translation error.

session

buffer

Specifies the buffering model for the initial JspWriter to handle the response generated by the page. If the value specifi is none Than there is no buffering and all out put is written immediately through PrintWriter. The size of the buffer can be specified in kilobytes, kb suffix is required otherwise translation error will occur. If a buffer size is specified then output is buffered with a buffer size not less than that specified. The default value is not less than 8kb

autoFlush

Indicates weather the buffered output should be flushed automatically when the buffer is full, or weather an exception should be raised indicating buffer overflow. autoFlush can not be set to true when buffer is none, otherwise it will resu in translation error.

isThreadSafe

Indicates the threading model to be used by JSP and generated servlet class. True means the JSP is thread safe and container can send multiple simultaneous requests to the page. Value of false means the JSP page is not thread safe and container must send a request at a time, in other words container must seriali the requests to JSP page Note: The Servlet 2.4 specification deprecates SingleThreadModel, which is the most common mechanism for JSP containers to implement isThreadSafe. Page authors are advised against using isThreadSafe, as the generated Servlet may contain deprecated code. Used to provide the information about the JSP page, any arbitrary string can be specified that can subsequently be obtained from the pages implementation of Servlet.getServletInfo method.

Info

isErrorPage

Indicates weather or not the page is intended to be an error page of some other JSP page. If value is true than an implic scripting language variable exception is available that references the exception. If the value is false than implicit object ex caption is unavailable and any attempt to use it within the body of the JSP page will result in translation time error.

errorPage

Defines the URL to another resource withing the currenct web application which is invoked if any checked or uncheck exception is thrown but not caught by the JSP pages implementation class. If the URL points to another JSP page than when that JSP page is invoked an implicit object exception is available which references the originating uncaught Throwable. When an uncaught exception occurs, JSP pages implementation servlet class catches the instance of Throwable and passes it to error page by setting it in ServletRequest using setAttribute() method, with the name of javax.servlet.jsp.jspException and javax.servlet.error.exception. The path of a servlet can also be specified as the value of errorPage attribute, In that case the original Throwable can b obtained by getAttribute() method of the request with any name specified above.

contentType

Defines the MIME type for the response of the JSP page and character encoding for the JSP page and response. This ca have either of the formMIMETYPE or MIMETYPE; charset=CHARSET. See http://www.iana.org/assignments/media-types/index.html for more information on MIME types. Default value for MIMETYPE of the generated response is text/html for jsp page in standard syntax and text/xml for JSP documents in XML syntax.

Defines the character encoding for the JSP page. pageEncoding If pageEncoding attribute is not defined and CHARSET is defined in contentType attribute than it will be used as character encoding of the page. Defines whether EL expressions are ignored or evaluated for

An example of JSP page directive


Following page directive imports List and ArryList classes so it can be used within page.
<%@page import=java.uitl.list, java.util.ArrayList/>

Following page directive specifies that the page is not thread safe so container serializes the requests to JSP page and will not send multiple simultaneous requests.
<%@page isThreadSafe=false/>

In JSP documents in XML format, page directive can be written as


<jsp:directive.page language="java," import="java.util.List/"> </jsp:directive.page>

Set the response encoding to UTF-8.


<%@page contentType="text/html; charset=UTF-8"/> <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <jsp-config> <taglib> <taglib-uri>http://jakarta.apache.org/taglibs/dbtags</tagliburi> <taglib-location>/WEB-INF/taglibs-dbtags.tld</taglib-location> </taglib> </jsp-config> </web-app>

XMLHTTPOBJECT METHODS There are actually not that many methods available on the XmlHttpRequest object. There are only 6 methods that the XmlHttpRequest can call.
abort()

This cancels the current request as expected.


getAllResponseHeaders()

Returns all the response headers as a key / value pair.


getResponseHeader(header)

This returns the value of the specified header.


open(method, url)

This prepares the XmlHttpRequest object for a call to the server. Method can either be POST, GET, or PUT. Url can be relative or absolute, but it should be known that you can't make cross domain calls for security reasons. If you need to make cross domain calls, you will have to do some work on the server side to make it happen correctly. If you are passing parameters with via GET, you can append them to the URL here.
send(body)

This method actually sends the request to the server. The body parameter can be used to pass any POST parameters that you would like. You can format your POST parameters just like a GET querystring.
setRequestHeader(header, value)

The final method allows you to set the specified header with the given value. You will most often use this function for setting the content type of the request. Those are the 6 methods available to you via the XmlHttpRequest object. Additionally, the XmlHttpRequest object also provides

XmlHttpRequest Properties In addition to the 6 methods available via the XmlHttpRequest object, you also have access to 6 properties.
onreadystatechange

This property sets the method to be called on every state change. This is usually your event handler for the asynchronous callback.
readyState

This property defines the state of the XmlHttpRequest. Possible values include: 0 1 2 3 4 Uninitated Loading Loaded Interactive Complete

When sending the XmlHttpRequest, you will check to see if the readyState is 0 or 4, and in your asynchronous callback handler, you will check to see if the readyState is 4.
responseText

This returns the response from the server as a string. If you are only returning one value this is the way to go because it is much easier that trying to walk the XML DOM.
responseXML

This returns the response from the server as an XML document. This is the way to go if you need to return multiple values from your AJAX request. It does require some knowledge of the XML DOM to use, but is quite powerful.
status

This returns the HTTP status code from the server such as 200 for OK or 404 for not found.
statusText

This returns a string representation of the HTTP status code such as OK for 200 and Not Found for 404 And that's is for the properties available to you via the XmlHttpRequest object.

Potrebbero piacerti anche