Thank you Mark. Based on your tips and further experiment, now I am able 
to use JSTL in dspace.

The procedure is very much similar to my previous description.

* copy the tld files from Apache Jakarta taglibs project's jstl package to 
WEB-INF of dspace. I am using v1.1.2 because it is the default preloaded JSTL 
in dspace. There are 15 tld files:

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

* add one or more tag directive statements at the top of the jsp page that you 
want to use JSTL:

Here is an example jsp unsing the core JSTL library. Note that the uri is 
"http://java.sun.com/jsp/jstl/*"; for library version 1.1.2.
My previous experiments did not work because I am missing "jsp" in the path.
 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
<html>
 <head>
   <title>Count to 10 Example (using JSTL)</title>
 </head>
 <body>
   <c:forEach var="i" begin="1" end="10" step="1">
     <c:out value="${i}" />
     <br />
   </c:forEach>
 </body>
</html>

* (this is optional) Add several directives in web.xml of dspace. Below 
is one of them:

  <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
  </taglib>

The benefit of adding these directives is that you can define another 
location to store the tld files. For example, you can put them in 
WEB-INF/tld/*.tld to make the directory tree look better.

The last requirement is that Tomcat version should be 5.x or above.

Hope that the above description could help developers to enable JSTL by 
default in future dspace versions, and also improve some jsp pages using 
JSTL. The xml and sql handling abilities of JSTL are particular 
attractive useful tools.

Allen.
HKU Hub Administrator, http://hub.hku.hk


Mark Diggory wrote:
> Allen,
>
> You are not getting EL working properly.
>
> DSpace 1.5.0 already comes with JSTL 1.1.2 provided, so you do not
> need to add the jars to the jspui webapp so you do not need to add
> them. You should already see:
>
> WEB-INF/lib/jstl-1.1.2.jar
> WEB-INF/lib/standard-1.1.2.jar
>
> I recommend reading through the following:
> http://wiki.apache.org/jakarta-taglibs/FrequentlyAskedQuestions
>
> Your trying to use EL syntax in your tags and there need to be some
> important settings in place for that to work...
>
> 1.) Make sure your using in your web.xml
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <web-app 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";
>  version="2.4">
>
> 2.) Make sure your using the right URL for your taglibraries:
>
> <%@ taglib uri="http: //java.sun.com/jsp/jstl/core" prefix="c" %>
>
> You should test if you really need to add the taglib directive to your
> web.xml first.  I seem to recall something about JSP checking in the
> jstl jar first for it.
>
> Good luck,
> Mark
>
> p.s. we should have had this added a long time ago, if you get it
> working please feel free to contribute the result back fro DSpace 1.6,
> likewise DSpace 1.5.2 has some significant fixes over 1.5.0, I would
> recommend using it if you can.
>
> On Thu, Jul 16, 2009 at 9:37 PM, Allen Lam<[email protected]> wrote:
>   
>> Hello developers,
>>
>> I am trying to use jstl for writing jsp in dspace.
>>
>> What I've done:
>> * added jar files from jstl package to WEB-INF/lib of dspace. I have
>> tried jstl-1.2.jar from EE5, and also 1.1.2 from Apache taglib project.
>> * added the tld files from jstl package to WEB-INF of dspace.
>> * added several <taglib> to web.xml of dspace (below is one of them)
>>
>> <taglib>
>>  <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
>>  <taglib-location>/WEB-INF/c.tld</taglib-location>
>> </taglib>
>>
>> * prepared a test.jsp in jspui of dspace:
>>
>> <%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %>
>> <html>
>>  <head>
>>    <title>Count to 10 Example (using JSTL)</title>
>>  </head>
>>  <body>
>>    <c:forEach var="i" begin="1" end="10" step="1">
>>      <c:out value="${i}" />
>>      <br />
>>    </c:forEach>
>>  </body>
>> </html>
>>
>> * open the test.jsp page from browser and get:
>> ${i}
>> ${i}
>> ${i}
>> ${i}
>> ${i}
>> ${i}
>> ${i}
>> ${i}
>> ${i}
>> ${i}
>>
>> No error message or exception in tomcat's/dspace's log.
>>
>> In a separated barebone webapp in the same server with similar setup, I
>> get numbers 1 to 10, which is the correct result.
>>
>> Is jstl clashing with dspace's own tag lib? How can I make jstl work
>> inside dspace?
>> My dspace version is 1.5.0.
>>
>> Any expert could show me the way to do it, or give a comment? Thanks.
>>
>> Allen.
>> HKU Hub Administrator, http://hub.hku.hk
>>
>>
>> ------------------------------------------------------------------------------
>> Enter the BlackBerry Developer Challenge
>> This is your chance to win up to $100,000 in prizes! For a limited time,
>> vendors submitting new applications to BlackBerry App World(TM) will have
>> the opportunity to enter the BlackBerry Developer Challenge. See full prize
>> details at: http://p.sf.net/sfu/Challenge
>> _______________________________________________
>> DSpace-tech mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/dspace-tech
>>
>>     

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech

Reply via email to