What are the compnents of Jsp?
>> Tuesday, June 14, 2011
COMPONENTS OF JSP :
JSP syntax is almost similar to XML syntax. The following general rules are applicable to all JSP tags.
1. Tags have either a start tag with optional attributes, an optional body, and a matching end tag or
they have an empty tag possibly with attributes.
2. Attribute values in the tag always appear quoted. The special strings ' and " can be used if quotes
are a part of the attribute value itself.
Any whitespace within the body text of a document is not significant, but is preserved, which means that any
whitespace in the JSP being translated is read and preserved during translation into a servlet.
The character \ can be used as an escape character in a tag, for instance, to use the % character, \% can be used.
JavaServer Pages are text files that combine standard HTML and new scripting tags. JSPs look like HTML,
but they get compiled into Java servlets the first time they are invoked. The resulting servlet is a combination of HTML from the JSP file and embedded dynamic content specified by the new tags. Everything in a JSP page can be divided into two categories:
1. Elements that are processed on the server
2. Template data or everything other than elements, that the engine processing the JSP engines.
Element data or that part of the JSP which is processed on the server, can be classified into the following categories:
1. Directives
2. Scripting elements
3. Standard actions
1.JSP directives serve as messages to the JSP container from the JSP. They are used to set global values such as class declaration,methods to be implemented, output content type, etc. They do not produce any output to the client. All directives have scope of the entire JSP file. That is, a directive affects the whole JSP file, and only that JSP file. Directives are characterized by the @ characterwithin the tag and the general syntax is:
The three directives are page, include and taglib.
2.Scripting elements are used to include scripting code (Java code) within the JSP. They allow to declare variables and methods,include arbitrary scripting code and evaluate an expression. The three types of scripting element are: Declaration, Scriptlets and Expressions.
A declaration is a block of Java code in a JSP that is used to define class-wide variables and methods in the generated class file.Declarations are initialized when the JSP page is initialized and have class scope. Anything defined in a declaration is available throughout the JSP,to other declarations, expressions or code.
A scriptlet consists of one or more valid Java statements.
A scriptlet is a block of Java code that is executed at request-processing time.
A scriptlet is enclosed between "<%" and "%>". What the scriptlet actually does depends on the code,
and it can produce output into the output stream to the client. Multiple scriptlets are combined in the
compiled class in the order in which they appear in the JSP. Scriptlets like any other Java code block or method,can modify objects inside them as a result of method invocations.
An expression is a shorthand notation for a scriptlet that outputs a value in the response stream back to the client. When the expression is evaluated, the result is converted to a string and displayed, An expression is enclosed within <%= and %> "<%=" and "%>". If any part of expression is an object, the conversion is done using the toString() method of the object.
3.Standard actions are specific tags that affect the runtime behavior of the JSP and affect the response sent back to the client. The JSP specification lists some standard action types to be provided by all containers, irrespective of the implementation.Standard actions provide page authors with some basic functionality to exploit; the vendor is free to provide other actions to enhance behavior.
JSP syntax is almost similar to XML syntax. The following general rules are applicable to all JSP tags.
1. Tags have either a start tag with optional attributes, an optional body, and a matching end tag or
they have an empty tag possibly with attributes.
2. Attribute values in the tag always appear quoted. The special strings ' and " can be used if quotes
are a part of the attribute value itself.
Any whitespace within the body text of a document is not significant, but is preserved, which means that any
whitespace in the JSP being translated is read and preserved during translation into a servlet.
The character \ can be used as an escape character in a tag, for instance, to use the % character, \% can be used.
JavaServer Pages are text files that combine standard HTML and new scripting tags. JSPs look like HTML,
but they get compiled into Java servlets the first time they are invoked. The resulting servlet is a combination of HTML from the JSP file and embedded dynamic content specified by the new tags. Everything in a JSP page can be divided into two categories:
1. Elements that are processed on the server
2. Template data or everything other than elements, that the engine processing the JSP engines.
Element data or that part of the JSP which is processed on the server, can be classified into the following categories:
1. Directives
2. Scripting elements
3. Standard actions
1.JSP directives serve as messages to the JSP container from the JSP. They are used to set global values such as class declaration,methods to be implemented, output content type, etc. They do not produce any output to the client. All directives have scope of the entire JSP file. That is, a directive affects the whole JSP file, and only that JSP file. Directives are characterized by the @ characterwithin the tag and the general syntax is:
The three directives are page, include and taglib.
2.Scripting elements are used to include scripting code (Java code) within the JSP. They allow to declare variables and methods,include arbitrary scripting code and evaluate an expression. The three types of scripting element are: Declaration, Scriptlets and Expressions.
A declaration is a block of Java code in a JSP that is used to define class-wide variables and methods in the generated class file.Declarations are initialized when the JSP page is initialized and have class scope. Anything defined in a declaration is available throughout the JSP,to other declarations, expressions or code.
A scriptlet consists of one or more valid Java statements.
A scriptlet is a block of Java code that is executed at request-processing time.
A scriptlet is enclosed between "<%" and "%>". What the scriptlet actually does depends on the code,
and it can produce output into the output stream to the client. Multiple scriptlets are combined in the
compiled class in the order in which they appear in the JSP. Scriptlets like any other Java code block or method,can modify objects inside them as a result of method invocations.
An expression is a shorthand notation for a scriptlet that outputs a value in the response stream back to the client. When the expression is evaluated, the result is converted to a string and displayed, An expression is enclosed within <%= and %> "<%=" and "%>". If any part of expression is an object, the conversion is done using the toString() method of the object.
3.Standard actions are specific tags that affect the runtime behavior of the JSP and affect the response sent back to the client. The JSP specification lists some standard action types to be provided by all containers, irrespective of the implementation.Standard actions provide page authors with some basic functionality to exploit; the vendor is free to provide other actions to enhance behavior.
0 comments:
Post a Comment