Sunday, 28 July 2013

JSP TAGS



JSP TAGS:


In this lesson we will learn about the various tags available in JSP with suitable examples. In JSP tags can be devided into 4 different types.
INTRODUCTION TO JSP TAGS
In this lesson we will learn about the various tags available in JSP with suitable examples. In JSP tags can be devided

    Directives

 In the directives we can import packages, define error handling pages or the session information of the JSP page.
General syntax for the page directive is

    <%@ page optional attribute ... %>

    Declarations

 This tag is used for defining the functions and variables to be used in the JSP.
Notation of the Declaration tag is shown below:
    <%!                    %>

     Scriplets

 In this tag we can insert any amount of valid java code and these codes are placed in _jspService method by the JSP engine.
<%!               
     statement1;
     statement2;      //Valid Java Code
     ..........;
%>                          //end of Scriptlet tag

    Expressions

We can use this tag to output any data on the generated page. These data are automatically converted to string and printed on the output stream.
<%!                  //start of declaration tag
     statement
       //Java Expression 
%>
                   //end of declaration tag 

    Action Tag:

Action tag is used to transfer the control between pages and is also used to enable the use of server side JavaBeans. Instead of using Java code, the programmer uses special JSP action tags to either link to a Java Bean set its properties, or get its properties.

General syntax of Action Tag:
    <jsp:action attributes />

<jsp:include page="{relativeURL | <%= expression %>}" flush="true" />

<jsp:include page="{relativeURL | <%= expression %>}" flush="true" />
 <jsp:param name="parameterName" value="{parameterValue | <%= expression %>}" />
 </jsp:include>


No comments:

Post a Comment