Creating Method in JavaServlet Page
Learn creating a method inside a JSP Page
Explanation
Methods is a small code segment that can be used within a JSP page to perform a specific operation.
Example for creating a method:
<%!
public int mul(int a, int b)
{
return a * b;
}
%>
Multiplication of two numbers:<%= mul(2, 2) %>
Result :
Multiplication of two numbers:4
In the above example we have used a method "mul" that will return a integer value as output. It takes two integers "a", "b" as parameters to produce the product of two numbers as output.