Monday 23 September 2013

jsp:param

<jsp:param>:

Defn:
Pass parameters to the included/forwarded page.

Syntax:
<jsp: include page="{PAGE_TO_INCLUDE}" flush="true">
 <jsp param name="{parameterName}" value="{paramValue}"/>
 </jsp include>




  • We have jsp include and jsp forward and even jsp include , we said that we can pass parameters to jsp include but we could pass parameters in jsp directive so how do you pass parameters to these two elements jsp include and forward.
  • Using the jsp param action element is used to pass parameters to  included or forwarded page.
  • Lets say that i want to include a page but the contents of the page is again the depends on certain values comes from the main page so lets say that in my included jsp page, in my footer page i want to display things like page 1 of 4 or page 2 of page . So I pass that value to the number of page using the jsp param so I pass page number in the parameterName and I pass  a value =1 or 2 or 3 in paramValue:  so display i can have certain kind of dynamic content based on the page which is actually included in my sub page in my included jsp page so it is not really completely static nature but it can also have dependancy  is on my main page  which is actually included this page.


Syntax 2:
<jsp:forward page="{PAGE_TO_FORWARD}" flush="true">
<jsp: param name="{parameterName}" value="{paramValue}"/>
</jsp:forward>

No comments:

Post a Comment