TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Sunday, 26 April 2020

JSP Declaration Tag In Java | JSP Declaration Tag In Java In Hindi | JSP Declare java Function

   JSP Declaration Tag

The JSP declaration tag is used to declare fields and methods.
The code written inside the jsp declaration tag is placed outside the service() method of auto generated servlet.

Syntax of JSP declaration tag

The syntax of the declaration tag is

      <%!  field or method declaration %>

image download for jsp decalaration tag

Fig: JSP Declaration Tag 


Example of JSP declaration tag that declares field

   In this example of JSP declaration tag, we are declaring the field and   printing the value of the declared field using the jsp expression tag. 

index.jsp


   <html>  
    <body>  
    <%! int data=50; %>  
    <%= "Value of the variable is:"+data %>  
     </body>  
     </html>  

Example of JSP declaration tag that declares method

In this example of JSP declaration tag, we are defining the method which returns the cube of given number and calling this method from the jsp expression tag. But we can also use jsp scriptlet tag to call the declared method.

index.jsp


     <html>  
     <body>  
     <%!   
    int cube(int n){  
     return n*n*n*;  
      }  
     %>   
     <%= "Cube of 3 is:"+cube(3) %>  
    </body>  
     </html>  



No comments:

Post a Comment