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?!?!
LVL 8
colr__Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ManishLeadCommented:
can you post the web.xml?
0
JaaxArchitectCommented:
Ensure that this is how the taglib is defined

taglib>        
<taglib-uri>mytags</taglib-uri>        
<taglib-location>/WEB-INF/taglib.tld</taglib-location>    
</taglib>

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
0
rrzCommented:
>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.
0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <taglib>
        <taglib-uri>mytags</taglib-uri>
        <taglib-location>/WEB-INF/taglib.tld</taglib-location>
    </taglib>
</web-app>
--------------------------------
0
rrzCommented:
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"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
your tags here in the proper order as posted by Jaax above
</web-app>

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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
0
rrzCommented:
Thanks for closing, but you should have split the points.  
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.