How JavaBeans Work In JavaServer Pages

It is easy to use JavaBeans with JavaServer Pages through a set of standard bean tags. The tag <jsp:useBean> fetches a bean instance from the PageContext according to the id attribute and exports it to a JSP script variable with the same name. If the named bean instance is not available, the <jsp:useBean> tag creates one and stores it in the PageContext for future use. Data property fields in a bean instance can be accessed from <jsp:getProperty> and <jsp:setProperty> tags throughout the JSP page. And a bean instance can also be accessed by the script variable exported by the <jsp:useBean> tag.

—M.J.Y. and N.R.

Back to Article