Jsp page
<HTML> <HEAD> <TITLE>Using <jsp:useBean></TITLE> </HEAD> <BODY> <H1>Using <jsp:useBean></H1> <jsp:useBean id="bean1" class="beans.Test2" /> The message is: <%= bean1.msg() %> </BODY> </HTML>
Test2.java
package beans; import java.io.Serializable; public class Test2 implements Serializable { public Test2() { } public String msg() { return "msg"; } }