Custom tag libraries and Java Beans are both ways to seperate logic from the content in JSP pages. Can you illustrate particular scenarios where it may be beneficial to use one over the other?

Simon Brown

I like to think of using JavaBeans for maintaining state in server side business objects or accessing other resources (EJB's, JavaMail, etc). I use JavaBeans as non-visual components and they do not contain any HTML rendering code.

I use custom tags to hide common functionality that generates dynamic HTML. These tags can gain access to the session information and thus make use of the JavaBeans.

So anything that contains HTML required in the delivered document is encapsulated into a custom tag, otherwise it's a JavaBean.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact