| Evolution of Web Application |
| |
| The Components of JSPs |
| |
| The universal system are applicable to all JSP tags: |
|
|
| 1. Tags have either a start tag with elective attributes, an optional body, or a matching end tag or they have an empty tag 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. |
| |
| |
| The whitespace within the body text of a document is not important, but is preserved, it means 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. |
| |
| |
| JSP page can be divided into two categories: |
| . Elements that are processed on the server |
| . 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: |
. Directives
. Scripting elements
. Standard actions |
| |
| |
| Directives |
| JSP directives serve as messages to the JSP container from the JSP. |
|
| These are used to set global values such as class declaration, methods to be implemented, output content type, etc. All directives have scope of the entire JSP file. |
| |
| Directives are characterized by the @ character within the tag. |
| |
| The three directives are page, include and taglib. |
|
| |
| |
| Scripting elements |
| Scripting elements are used to include scripting code (Java code) within the JSP. It allows declaring 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 building block of Java code in a JSP which 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 is a block of Java code that is executed at request-processing time. A scriptlet is enclosed between. What the scriptlet really 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 document for a scriptlet that outputs a value in the response stream back to the client. When the expression is evaluated, the outcome is converted to a string and displayed, an expression is enclosed within. If any part of expression is an object, the conversion is done using the toString () method of the object. |
| |
| |
| Standard actions |
| Standard actions are exact tags that influence the runtime behavior of the JSP and affect the answer 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. |
| |
| |
|
| |
| |
| |