Jsp useBean


Prev Tutorial Next Tutorial

Jsp useBean

<jsp:useBean> standard action tag is use to establish a connection between a jsp page and a java bean.

In web applications of java, jsp and java bean communication is required in the following two cases:

  • In a real-time MVC project, a model class (business class) will set the data to a java bean and a jsp (view) will read the data from a bean and finally displays it on the browser. In this class jsp to a java bean communication is required.
  • If multiple jsp pages need common java logic then it separates that java code into a bean and then we call the bean from jsp. In this case also jsp to java bean communication is required.

<jsp:useBean> tag is used for creating an object of a bean class in a jsp page.

Example


Every java class is not a java bean automatically. A class should have the following qualities to make it as a java bean.

  • Class must be public.
  • Class must contain default constructor.
  • Each private property of the class must have setter or getter or both methods.
  • A class can at most implement Serializable interface.

Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements