jsp taglib & resource uri configuration

hi,

I'd like to ask question, probably a stupid one. Sorry about it, but I can't figure it out.

I've got here simple JSP page, with core taglib, it includes line like this:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
and this line is marked as an error.

1.Under given uri is just some not very well maintained page, not giving much valuable informations.
2.JSTL 1.2 should be part of EE application servers, so it does sound as a good to me to including .tld files or jstl jars in my project. Or should I do it?
3.I'm aware of 'Resources' tab in Settings, but to *what* should I point that uri?

Question two: I've got here simple web app, configured to use JBoss.
given line is marked as an error. When I add dependency to jstl.jar error goes away.

4. how's that possible?
5. as mentioned in 2) JSTL is part of EE, quoting java EE tutorial: "This library is automatically loaded into the classpath of all web applications running on the Application Server ...", so what is the proper way of getting rid of error, and why it is even occuring assuming JBoss is an application server?

Thanks in advance,
martin
2 comments
Comment actions Permalink

alfonz19 wrote:

JSTL 1.2 should be part of EE application servers, so it does sound as a good to me to including .tld files or jstl jars in my project. Or should I do it?

IDEA needs access to the JSTL classes and the TLDs so it knows what is (and isn't) available in the taglib. So you'll need to include it in your project but with a scope of "provided". This way it is available to idea while editing, but IDEA will not included it in the build since you are  that it is provided at runtime (by the web container in this case). If using maven, added <scope>provided</scope> to the dependency declaration for the JSTL library. If using IDEA's project dependency configuration, you can set the scope to "provided". I have found with the JSTL, the easiest thing is to create a JAR that has all the TLD's in a directory in <jar-root>/META-INF/tld (or just <jar-root>/META-INF). The default jar from the apache reference implementation (https://tomcat.apache.org/taglibs/standard/) does not include the TLDs in the JAR. That way I do not have to deal with adding the TLDs separately. But it sounds like the JSTL.jar you are using (from JBoss) has the TLDs in it.

alfonz19 wrote:
I'm aware of 'Resources' tab in Settings, but to *what* should I point that uri?

The resources settings do not apply in this situation. IDEA simply need to "see" the TLD in one of the standard places (and have the classes on the classpath as well I believe). The standard places for JSP 2.0 or greater are:

  •     directly inside WEB-INF
  •     directly inside a sub-directory of WEB-INF
  •     inside the META-INF directory inside a JAR file that is inside WEB-INF/lib, or in the case of IDEA a JAR that is a dependency
  •     inside a sub-directory of the META-INF directory inside a JAR file that is inside WEB-INF/lib, or in the case of IDEA a JAR that is a dependency

For JSP 1.x, you need to add a <taglib> mapping to the web.xml deployment descriptor.

alfonz19 wrote:
Question two: I've got here simple web app, configured to use JBoss.
given line is marked as an error. When I add dependency to jstl.jar error goes away.

4. how's that possible?
5. as mentioned in 2) JSTL is part of EE, quoting java EE tutorial: "This library is automatically loaded into the classpath of all web applications running on the Application Server ...", so what is the proper way of getting rid of error, and why it is even occuring assuming JBoss is an application server?

As mentioned above, while it is available to your JBoss server, it is not available to IDEA while you are editing the code. So you need to added it with a scope of "provided".

0
Comment actions Permalink

Thanks a lot for your explanation. Everything is clear now.

0

Please sign in to leave a comment.