Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL vs. javabeans  RSS feed

 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. If somebody has a minute, I've been revisiting the use of JSTL after working on some other things for some time. One thing that is kinda occuring to me is the tagclass tag in the tld...is this meant to replace, or it seems to me it could replace, the jsp:useBean... on the jsp? I could declare some sorta collection as an attribute and the tagclass would return it like a javabean method, right? (then use EL syntax to reference the collection on the jsp). Thank you very much for reading this.
[ October 27, 2005: Message edited by: Tom Griffith ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is the tagclass tag in the tld.


I'm not sure what you mean by this. The <tag-class> element in a tld file is used to identify the class used to implement a custom tag that is being defined within the tld.

It really doesn't have much to do with scoped variables (javabeans stored in the scoped contexts) and not much to do with <jsp:useBean>.

To address the subject of your topic: in a scriptless JSP page using the JSTL, the utility of <jsp:useBean> is greatly diminished. Since no scripting variables are necessary on the page, <jsp:useBean> is no longer necessary to attach such scripting variables to corresponding scoped variables. But recall that <jsp:useBean> can also cause a scoped variable to come into existence (if a scoped variable of the specified scope and id do not already exist), and so I have seen <jsp:useBean> still used in scriptless JSP pages in order to instantiate scoped variables not already made resident by the controller servlet.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should also add that javabeans themselves are alive and kicking in the JSTL/EL/scriptless JSP world. In fact, scoped variables -- the term for javabeans and other objects stored in the scoped contexts -- have taken center stage in favor of scripting variables.

So there's certainly no vs. between the JSTL/EL and Javabeans. They were made to go hand in hand.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear. Thank you for the information. The source of my question was the setAttribute() method within doTag() for a Simple Tag. It seemed to me that this does a lot of work javabeans could/would do. But like you said, javabeans can bring new variables into existence. Is this accurate?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The source of my question was the setAttribute() method within doTag() for a Simple Tag. It seemed to me that this does a lot of work javabeans could/would do.


Well, no. What is it that you are going set into the context using the setAttibute() method? Usually a javabean!

The setAttribute() method of any of the context scopes can be called from anywhere that a reference to the context is available -- including within custom tags. And it's always been that way.

So I'm still not sure why you are thinking that javabeans are any less important than before -- quite the opposite, as I pointed out.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!