Use the exclamation mark.
<%!
public void doSomething() {
// Implement.
}
%>
Although rather use servlets or beans for business logic and use JSP for display only.