In the context of a JSP page, both accomplish similar goals but the differences are:
custom tags | javabeans |
Can manipulate JSP content | Can't manipulate JSP content |
Custom tags can simplify the complex operations much better than the bean can. But require a bit more work to set up. | Easier to set up |
Used only in JSPs in a relatively self-contained manner. Can be used in both Servlets and JSPs. | You can define a bean in one Servlet and use them in another Servlet or a JSP page. |
JavaBeans declaration and usage example:
<jsp:useBean id="identifier" class="packageName.className"/> <jsp:setProperty name="identifier" property="classField" value="someValue" /> <jsp:getProperty name="identifier" property="classField" /> <%=identifier.getclassField() %> |