Thursday, July 31, 2008
XML
XML was designed to transport and store data.
Introduction to XML
Before you continue you should have a basic understanding of the following:
HTML
JavaScript
-------------
What is 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
Wednesday, July 30, 2008
Wednesday, May 7, 2008
Monday, May 5, 2008
JSP Custom Tags
http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html
Working of custom tags: 3 steps are involved in working of JSP custom tags.
1. Defining the tag handler: This is the java class which actually works behind the scenes to produce the required output in the JSP page. The class can accept attribute value from the calling JSP page and produces output accordingly.
2. Defining the Tag library descriptor: All tag handlers which actually produce the necessary output with individual tag names are included in a library are defined in a tld file called the tag library descriptor.
3. Using of custom tags in JSP file:
A tag library is a collection of custom tags.
Custom actions are invoked using custom tags which are reusable modules to perform actions like form processing, accessing databases , email and directories, and flow control.
Java beans were used previously for these purposes.
Features include:
. can be customized via attributes passed from the calling page.
. have access to all the objects available to JSP pages.
. can modify the response generated by the calling page.
. can communicate with each other.
Types of Tags
Simple tags: Tags with no body or attributes. Directly invokes an action.
Tags with attributes: The start tag can contain attributes in the form attr="value".
Attributes help customize the behavior of a tag just as parameters are used to affect the outcome of executing a method on an object.
Ex:
Tags with a body
Tags That Define Scripting Variables
Cooperating Tags
JSP Implicit objects
request
response
Session
Out
PageContext
Application
Config
Page
Exception
Java Server Pages
Benefits for Developers.
- Use JSP technology without having to learn the Java language.
- Extend the JSP language: Java tag library developers and designers can extend the JSP language with "simple tag handlers," which utilize a new, much simpler and cleaner, tag extension API.
- Easily write and maintain pages: The JavaServer Pages Standard Tag Library (JSTL) expression language is now integrated into JSP technology and has been upgraded to support functions.
Working and architecture of JSP
JSPs are compiled into Java Servlets by a JSP compiler. A JSP compiler may generate a servlet in Java code that is then compiled by the Java compiler, or it may generate byte code(class file that is generated after compilation) for the servlet directly. JSPs can also be interpreted on-the-fly reducing the time taken to reload changes.
1. A user visits a website made using JSP technology. The requests for a webpage are made by clicking on a link or by entering a URL address or by clicking a SUBMIT on a web user form.
2. The request is carried via HTTP GET or POST commands to the webserver, which is then passed to servlet container.
3. The servlet container then passes the request to the appropriate servlet generated after the compilation of the JSP into a servlet.
4. It is here the servlet container passes the objects of classes HttpServletRequest and HttpServletResponse as arguments to the methods of the servlet.
5. The servlet receive the request objects which contains packaged info like info about request URL, cookies, sessions and more useful info.
6. The servlets processes the request and generates the required html which is then passed via the HttpSerlvetResponse object, back to the serlvet container, then to the web server and then via the HTTP to the web browser of the user.
JSP syntax
A JavaServer Page may be broken down into the following pieces:
- Static data such as HTML .
- JSP directives such as the include directive .
- JSP scripting elements and variables .
- JSP actions .
- Custom tags with correct library