Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding <taglib> to web.xml

Posted on 2007-04-07
7
Medium Priority
?
6,206 Views
Last Modified: 2013-11-24
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?!?!
0
Comment
Question by:colr__
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 11

Expert Comment

by:Manish
ID: 18869636
can you post the web.xml?
0
 
LVL 10

Expert Comment

by:Jaax
ID: 18869683
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
 
LVL 28

Expert Comment

by:rrz
ID: 18869743
>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
Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

 
LVL 8

Author Comment

by:colr__
ID: 18869938
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
 
LVL 28

Accepted Solution

by:
rrz earned 2000 total points
ID: 18869990
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
 
LVL 8

Author Comment

by:colr__
ID: 18870245
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
 
LVL 28

Expert Comment

by:rrz
ID: 18870744
Thanks for closing, but you should have split the points.  
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question