I have a custom JSP taglib included in my JSP page w开发者_如何学Gohich says
<%@ taglib uri="xyz" prefix="xyz" %>
Where and how can I find out where is this defined exactly?
And also if I have a statement like
<xyz:cssurl fileName="myCSS.css"/>
Can it dynamically include different CSS and if yes, how?
The uri is just an identifier. It doesn't have to be an actual URI. Look at your web.xml: it might be defined there. If it isn't, look at all the jars used by your web app, and see if their META-INF folder includes a .tld file where this uri is defined.
Now for your second question (can it dynamically include different CSS and if yes, how?), I don't understand exactly what you're asking. But since no-one including yourself knows what the xyz taglib is, it's hard to answer. Once you have found the tld file for this taglib, you should find the description and expected parameters of this tag. The only thing that I might tell is that you could of course use this tag several times:
<xyz:cssurl fileName="myCSS.css"/>
<xyz:cssurl fileName="mySecondCSS.css"/>
<xyz:cssurl fileName="myThirtCSS.css"/>
The standard way to define a taglib is to define the URI for the taglib. It could be the location on your website or any other web site. There are hundreds of taglib available for different purpose. It all depends on what environment you are working on.
Simple taglib can be defined which is located at your localhost. http://localhost:8080/taglib.tld
<% @ taglib uri="/taglib.tld" prefix="helloWorld" %>
now you can use this tag through the prefix
which in helloWorld
in this case.
<html><body>
<helloWorld:image />
</body></html>
There is one common core JSTL which is very common in JSPs and it is prefixed by c.
There are many examples available for this library.
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
Please go through these Examples, you will have a very good idea about some basic/core JSTL and their usage.
You would probably be able to add CSS file dynamically after this tutorial. :) but to assist you let me give you a simple solution regarding this.
<c:forEach var="cssURI" items="${MyURICollection}">
<xyz:cssurl fileName="${cssURI}"/>
</c:forEach>
where MyURICollection
has all the CSS filename which is to added dynamically.
精彩评论