Friday, September 25, 2015

Remembering JSP Actions

JSP  mainly has 4 Types of actions

useBean
   Jsp usebean is used to associate a variable with an instance of a class . An example  is :

 <jsp:useBean id="today" class="java.util.Date"/>


setProperty and getProperty

    These actions are used to set or get property values from the variables defined using useBean  an Example :

 <jsp:useBean id="employee" class="testpackage.Employee"/>
<jsp:setProperty name="employee" property="firstName" value="someName"/>
First Name: <jsp:getProperty name="employee" property="firstName"/>


JSP Include and Forward 

    Jsp Include is used to include another resource dynamically . This should be a JSP page .
Difference between a JSP include and an Include directive is that , the JSP include adds the resource to the page in runtime while the other does in the time of translation .

  JSP forward forwards the current page to a different resource

No comments:

Post a Comment