FAQ


Advertisement



Can I define a method in a JSP page?

Yes, you can. A JSP declaration is used to declare variables and methods in a page’s scripting language. The syntax for a declaration is as follows:

You must declare the variable or method before you use it in the JSP file. See JSP Declaration  in JSP document.
For example,

 

<%! 
    public int getNumber() {
        ....
        return num;
    }
%>
 
My number is <%=getNumber()%>

 

 


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |