Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

detecting taglib present or missing

 
chris coleman
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose you're writing a jsp page that is meant to use certain tags out of a given taglib.
And what if the jsp page uses tags that do not exist in any imported taglib...? Maybe you are inadvertently importing an older version of the taglib.
Will those tags will simply not generate any visible output on the screen?
How could you detect the missing tag code and redirect the user to a page that says.. "hey, you have to install the xxxxxx taglib." ?
 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In event of usage of wrong version of taglib, compiling of JSP page itself will be a problem
 
Billy Bacon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you attempt to use a tag that the compiler cannot find in a tag library due to not import the taglib directive it resides in or if the .tld file doesn't contain the tag you are attempting to use, the comiler should complain that it knows nothing about the tag you are using and throw an error.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using an incorrect prefix, then the compiler has no way of telling since those tags might actually be a part of your output. After all, you could be using JSP to generate XML instead of HTML. However, if you've got the prefix correct and the tag name incorrect, you will get an error from the JSP compiler.
If you really want to add some validation to the page, to check for old versions of tags for example, check out the TagLibraryValidator class from the javax.servlet.jsp.tagext package.
HTH
Simon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic