Code snippet below shows how to define and use methods in JSP.
Java Code:
<%!
public String sayHello(){
    return "Hello";
}
%>


<%= sayHello() %>