A JSP useBean declaration in code is not required.
Just use
<body>
<%
MyClass tc = new MyClass();
tc.testMethod();
%>
</body>
But it will NOT print anything on the JSP. It just prints Helloto the server console. To print Helloin JSP, you need to return a String from the jper helper class MyClass, and then use the JSP output stream to display it.
Something like that:
In java class
public String testMethod(){
return "Hello";
}
And then in JSP
out.print(tc.testMethod());
source
share