This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes detecting taglib present or missing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "detecting taglib present or missing" Watch "detecting taglib present or missing" New topic
Author

detecting taglib present or missing

chris coleman
Ranch Hand

Joined: Mar 06, 2002
Posts: 42
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." ?


Sun Certified Java Programmer for the Java2(tm) Platform<br />IBM Certified Solution Developer, WebSphere 3.5
Bhushan Jawle
Ranch Hand

Joined: Nov 22, 2001
Posts: 249
In event of usage of wrong version of taglib, compiling of JSP page itself will be a problem
Billy Bacon
Greenhorn

Joined: Apr 03, 2003
Posts: 2
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

Joined: May 10, 2000
Posts: 1913
    
    6
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: detecting taglib present or missing
 
Similar Threads
tld files for struts 1.3.5
CustomTag - UnknownTag in Eclipse
Tag libraries
How to access to ValueStack from xml?
problem with JSTL