Adding <taglib> to web.xml

Hi, Im using Intellij IDEA and working through a JSTL book. When I try and add the <taglib> directive to my web.xml file to reference the jstl tags, Intellij highlights the directive as being invalid for web.xml.

I dont understand why the book says ive to add the taglib tag, but intellj wont let me do it?!?!
Who is Participating?
rrzConnect With a Mentor Commented:
I don't really know if you can use JSTL 1.0 with Tomcat 5. But you might try using this.
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

your tags here in the proper order as posted by Jaax above

Since you are using Tomcat 5, you should really use JSTL 1.1.2  and stay with the root tag you posted in your web.xml.
 In Servlet 2.4  the order of elements in your web.xml does not matter.
can you post the web.xml?
Ensure that this is how the taglib is defined


Also ensure that the taglib tag appears in the order specified below

<!ELEMENT web-app (icon?, display-name?, description?, distributable?,
context-param*, filter*, filter-mapping*, listener*, servlet*,
servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?,
error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*,
login-config?, security-role*, env-entry*, ejb-ref*,  ejb-local-ref*)>

Some of the tags are not mandatory. What is important to maintain the order of the tags
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

>I dont understand why the book says ive to add the taglib tag, but intellj wont let me do it?!?!  
Is it an old book ? Does it describe JSTL 1.0 ?    If you are using JSTL 1.1(and JSP 2.0) then the TLD's are in the jars. There is no need to add anything to your web.xml in order to use JSTL 1.1  .  Just put the jars in your classpath. If you are using Tomcat 6  put the jars in  <TomcatHome>/lib. If you are using Tomcat 5 then put them in <TomcatHome>/common/lib.
colr__Author Commented:
rrz@871311 - yeh, im using 1.0 jstl, following what the book is using, although im also using tomcat 5. So I need to add the tld files. Although I can use 1.1 jstl, Id rather work with what the book is using for the timebeing.

Jaax - I copied your example, and checked the ordering but intellij is still highlighting it in red, with a comment 'element taglib is not allowed here'. Ive listed my web.xml below - perhaps im using the wrong DTD? It was auto-generated by Intellij.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
         xsi:schemaLocation="" >

colr__Author Commented:
rrz@871311 - changed the dtd and it sorted the problem. Im obviously not using the most up to date versions, but I I would rather stick to to the book for the timebeing then look at the new develoments once Ive got that sorted.

Thanks for the help.
Thanks for closing, but you should have split the points.  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.