wood burning stoves 2.0*
The moose likes JSP and the fly likes Versions of JSTL and EL on a legacy project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Versions of JSTL and EL on a legacy project" Watch "Versions of JSTL and EL on a legacy project" New topic
Author

Versions of JSTL and EL on a legacy project

bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Greetings.

We're trying to bring a legacy application up to speed by introducing both JSTL and EL, and need a little help knowing what we HAVE to modify and what can stay the same.

Here are the details of our current environment:

  • Websphere 6.1 | Servlet Spec 2.4 / JSP 2.0
  • Struts 1.1
  • web deployment descriptor code (web.xml) = <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
  • standard.jar and jstl.jar are in place under WEB-INF


  • I know that we'll have to use JSTL 1.1 instead of 1.2 since we're tied to JSP 2.0 and that's fine.

    Here are a few questions:

  • The "powers that be" may not allow an update to the web.xml. Will the current 2.3 reference above work for JSTL 1.2 and EL?
  • The "powers that be" may also not allow a direct reference to sun for the tlds, so we'd have to actually place them in our WEB-INF folder (which is fine). If we do this, do we have to update the web.xml with references to them or is that no longer necessary with this version?


  • Thanks for your help with these questions!

    "...and the Truth will set you free."
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60752
        
      65

    The EL will not be enabled by the 2.3 DTD.

    You may be able to enable the EL on a page-by-page basis with directives.

    Tell the "powers that be" they're making a blunder. Either update the app or don't. Half-measures are just going to create more problems than they solve.


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    bryan nelson
    Ranch Hand

    Joined: Jun 16, 2003
    Posts: 95
    If I did (somehow) manage to get someone's ear about updating the DTD...would there be any issues in the existing app if we updated it to 2.4?
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60752
        
      65

    Unlikely. Pretty much everything will be backward compatible. One issue might be if you have any strings that start with '${" in the jsps -- but that's independent of 2.3 vs 2.4.
    bryan nelson
    Ranch Hand

    Joined: Jun 16, 2003
    Posts: 95
    Ok great.

    And if we do have to include the taglibs directly under our WEB-INF instead of hitting sun's url...which of these do I want. They all came packaged with JSTL 1.1:

    c-1_0.tld
    c-1_0-rt.tld
    c.tld
    fmt-1_0.tld
    fmt-1_0-rt.tld
    fmt.tld
    fn.tld
    permittedTaglibs.tld
    scriptfree.tld
    sql-1_0.tld
    sql-1_0-rt.tld
    sql.tld
    x-1_0.tld
    x-1_0-rt.tld
    x.tld

    Thanks!
    Stefan Evans
    Bartender

    Joined: Jul 06, 2005
    Posts: 1016
    The "powers that be" may also not allow a direct reference to sun for the tlds


    You are referring to the uri to import the tag library?: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

    It doesn't actually reference the tld from sun.
    Sure it looks like a URL, but its not. Go ahead - try it in your browser. You will find it now directs you to an oracle page about JSTL, not to the tld itself.

    It is actually a URI, which is something related, but different.

    Basically that uri is referring (indirectly) to the tld bundled with jstl. The container is implicitly defining tag library URIs based upon tld files it finds bundled in jars in the WEB-INF/lib directory.

    If you take a look in the tld for jstl core library: c.tld (it's bundled in standard.jar under the META-INF folder)
    you will see the following:


    Note that last element: uri? Thats what it is matching the taglib entry against.
    It doesn't need to access anything on the internet to do that.

    All of the gory details can be found in the JSP specification. JSP7.3 is the relevant bit to show the powers that be. Particularly 7.3.1 and 7.3.4

    The bottom line: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> does NOT make a direct reference to sun for the tlds.

    ----------
    regarding updating the web.xml file, there will be a few minor adjustments to web.xml other than just changing the declaration at the top.
    For instance in the 2.4 schema, tag libraries get declared in a <jsp-config> sub-element rather than as top level elements themselves.
    However as detailed above tag libraries can be imported implicitly from jar files, without having to be referenced from web.xml, so I prefer not to have <taglib> entries in web.xml in any case.


    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60752
        
      65

    bryan nelson wrote:The "powers that be" may also not allow a direct reference to sun for the tlds, so we'd have to actually place them in our WEB-INF folder


    Good lord, I missed this.

    Do the "powers that be" know anything?

    As Stefan points out, that's just a URI, it could be "fred" or "adksjfhdsaflgfjkdsghfjhdgsjkhfds".

    Ay-yi-yi!
    bryan nelson
    Ranch Hand

    Joined: Jun 16, 2003
    Posts: 95
    Oh man. Do I have egg on my face.

    Thanks so much for clearing up the URI reference. This is extremely helpful and good for our current purposes. Basically we'll be able to use JSTL 1.1 and EL even if I can't convince anyone to alter the web.xml. I tried using the



    page directive with the current 2.3 DTD and it works great. So we can at least go that route if nothing else.



    Thank you each for your time in this thread...and hopefully it will help out others as well.

    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60752
        
      65

     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Versions of JSTL and EL on a legacy project
     
    Similar Threads
    SCWCD x SCBCD
    Does Weblogic 8.1 platform support JSTL 1.1
    Variable defined in one JSP scriptlet not visible in another
    JSTL 1.1 and Tomcat 5 basic problem
    Ignore Expression Language (EL) Evaluation