A javabean is a class that conforms to certain standard conventions. That way the Servlet container can find your data. You can download the specification at
http://www.oracle.com/technetwork/java/javase/documentation/spec-136004.html
For a Servlet container, the javabean must be in a package.
package rrz; import java.util.Random; public class IdBean implements java.io.Serializable { private String randomId = null; public String getRandomId(){ //return randomId; // this would be the standard line //you can substitute your own code here or call your utility class return Integer.toString(new Random().nextInt()); } public void setRandomId(String randomId){ this.randomId = randomId; } }
and example jsp is as follows:
<jsp:useBean id="myBean" class="rrz.IdBean" /> value="${myBean.randomId}"