• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Tag - Sending/Setting an Attribute in the JSP

 
Rod Nichols
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have a JSP where I am trying to replace the scripting with EL, Tag Handlers, etc. I have some scripting that checks an ArrayList to see if it is null and if it has more than one element. The attribute name for this ArrayList has been set in an earlier servlet. I am thinking of creating a Simple Tag in the JSP. I know how to get the attribute name of the ArrayList into my tag, but I am not sure how to return a value back to the JSP ? Maybe I am making this more complicated than it needs to be, do I just need to set a variable/attribute in the tag handler code and it will be available to the JSP ? It doesn't have to be anything fancy, a boolean will do.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never reinvent the wheel. Assuming that the scoped variable's name is myVariable you can check for null or not empty with:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But generally, yes, you can create scoped variables in tag handlers.
 
Rod Nichols
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear, I am learning a lot about custom tags and the JSTL. You have been a big help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!