Test.java
package beans; public class Test { public Test() { } public String msg() { return "Hello from JSP!"; } }
Jsp page
<%@ page import="beans.Test" %> <HTML> <HEAD> <TITLE>Using a JavaBean</TITLE> </HEAD> <BODY> <h1>Using a JavaBean</h1> <% Test messager = new Test(); %> The message is: <%= messager.msg() %> </BODY> </HTML>