JSP: question: how to make tld-files part of the taglib library like STL is able to do?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JSP: question: how to make tld-files part of the taglib library like STL is able to do?

Rony G. Flatscher (Apache)
The STL (standard tag library) jstl-1.2_1.jar is able to have its tags processed without requiring
the user to place its tld-files into the webapps WEB-INF directory. Rather jstl-1.2_1.jar stores the
tld files in its META-INF directory and yet they seem to be found by the JSP processor (not sure
whether this is the correct term).

How can this be achieved for any taglib? What needs to be done to allow including the tld-files
within the taglib library such as to become able to remove the need to place the taglib library's
tld files into the webapps WEB-INF directory?

---rony



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: JSP: question: how to make tld-files part of the taglib library like STL is able to do?

markt
On 10/03/2021 13:19, Rony G. Flatscher (Apache) wrote:
> The STL (standard tag library) jstl-1.2_1.jar is able to have its tags processed without requiring
> the user to place its tld-files into the webapps WEB-INF directory. Rather jstl-1.2_1.jar stores the
> tld files in its META-INF directory and yet they seem to be found by the JSP processor (not sure
> whether this is the correct term).
>
> How can this be achieved for any taglib? What needs to be done to allow including the tld-files
> within the taglib library such as to become able to remove the need to place the taglib library's
> tld files into the webapps WEB-INF directory?

<quote spec="JSP" section="7.3.1">
When deployed inside a JAR file, the tag library descriptor files must
be in the META-INF directory, or a subdirectory of it.
</quote>

You also need to make sure that Tomcat isn't configured to skip your JAR
file when scanning for tag libraries (see
CATALINA_BASE/conf/catalina.properties).

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: JSP: question: how to make tld-files part of the taglib library like STL is able to do?

Rony G. Flatscher (Apache)
On 10.03.2021 14:44, Mark Thomas wrote:

> On 10/03/2021 13:19, Rony G. Flatscher (Apache) wrote:
>> The STL (standard tag library) jstl-1.2_1.jar is able to have its tags processed without requiring
>> the user to place its tld-files into the webapps WEB-INF directory. Rather jstl-1.2_1.jar stores the
>> tld files in its META-INF directory and yet they seem to be found by the JSP processor (not sure
>> whether this is the correct term).
>>
>> How can this be achieved for any taglib? What needs to be done to allow including the tld-files
>> within the taglib library such as to become able to remove the need to place the taglib library's
>> tld files into the webapps WEB-INF directory?
>
> <quote spec="JSP" section="7.3.1">
> When deployed inside a JAR file, the tag library descriptor files must be in the META-INF
> directory, or a subdirectory of it.
> </quote>
>
> You also need to make sure that Tomcat isn't configured to skip your JAR file when scanning for
> tag libraries (see CATALINA_BASE/conf/catalina.properties).

Thank you very much!

It turns out that I forgot to adjust the uri value in the JSP files to match the uri defined in the
tld files! :(

The reason why I thought that something was wrong with the jar file and the tld locations within
(despite having them in META-INF) was the following entry in the log file:

    ... cut ...
    10-Mar-2021 15:13:14.264 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory
    Deploying web application directory [D:\Apache Software Foundation\Tomcat 9.0\*webapps\aa_rgf_test*]
    10-Mar-2021 15:13:16.362 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars /At least one
    JAR was scanned for TLDs yet contained no TLDs/. Enable debug logging for this logger for a
    complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs
    during scanning can improve startup time and JSP compilation time.
    10-Mar-2021 15:13:16.362 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory
    Deployment of web application directory [D:\Apache Software Foundation\Tomcat
    9.0\webapps\aa_rgf_test] has finished in [2,098] ms
    ... cut ...

So actually the log message means what it states: there was at least one jar that did not contain a
TLD file (I read it: no TLD files were found in the scanned jars)! :)

Very sorry for the noise, typical user error. :(

Yet, now it is possible to forgo the current need to copy the tld files to the WEB-INF directory,
which is really great!

---rony