Solved

JSP file can't find the functions library

Posted on 2007-12-03
11
2,175 Views
Last Modified: 2013-11-24
I am trying to use a subtring function in a JSP file, so I added this line:
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

I still get this error when I try to compile all jsp files:
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/functions cannot be resolved in either web.xml or the jar files deployed with this application

I'm using Apache Tomcat Web container 5.5.17, JDK 1.5, JSTL 1.2, JSP 2.0
This should meet all the requirements for me to use functions, so I don't know what I'm doing wrong.
<%@ page contentType="text/html;charset=UTF-8"%>

<%@ page pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

<%@ taglib prefix="cp" uri="/WEB-INF/tlds/cp-taglib.tld" %>

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<%@ page import="com.sct.pipeline.uportal.channels.announcements.DisplayBean" %>
 
 
 

<jsp:useBean id="disBean" scope="request" class="com.sct.pipeline.uportal.channels.announcements.DisplayBean"/>
 

<fmt:setBundle basename="com.sct.pipeline.uportal.channels.announcements.display-ta-channel"/>
 

<SCRIPT LANGUAGE="JavaScript">

<c:if test="${disBean.hasMsgs && disBean.renderingAsRoot}">
 

function doDelete( theForm )

{

    var checkboxes = theForm.deleteID;

    var howMany = 0;

    if ( checkboxes )

    {

        if ( checkboxes.length )

        {

            for ( var i=0; i < checkboxes.length; ++i )

                if ( checkboxes[i].checked ) ++howMany;

        }

        else

        {

            if ( checkboxes.checked )

                howMany = 1;

        }

    }

    if ( howMany == 0 ) 

    {

        alert( "<cp:toJavaScript><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.deletion.none"/></cp:toJavaScript>" );

        return false;

    }

    var msg = "<cp:toJavaScript><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.deletion.one"/></cp:toJavaScript>";

    if (howMany > 1)

        msg = "<cp:toJavaScript><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.deletion.more.than.one"/></cp:toJavaScript>";

    return confirm( msg );

}

</c:if>

<c:if test="${disBean.annBean.id != 0}">
 

function doDeleteOne( theID )

{

    if ( confirm( "<cp:toJavaScript><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.deletion.one.confirm"><fmt:param><concat>theID</concat></fmt:param></fmt:message></cp:toJavaScript>" ) )

        document.location = "<c:out value="${disBean.baseURL}"/>?detailMode=yes&deleteID=" + theID;

}

</c:if>

</SCRIPT>
 

<c:choose>

<c:when test="${!disBean.renderingAsRoot}">

 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="personal_abm_tbl">
 

   <tr><td><font size="1" color="blue">

   <c:set var="name2" value="tag.9c1ec475f7c9df56.render.userLayoutRootNode.target.n267.uP123" />

   <c:set var="name3" value="${fn:substring(name2,21,4 )}"  />

   <c:out value='${name3}' />

   </font></td></tr>
 

<c:if test="${disBean.msgCount == 0}">

  <c:if test="${disBean.baseURL != 'tag.9c1ec475f7c9df56.render.userLayoutRootNode.target.n267.uP'}">

   <tr>

    <td>

    <span class="uportal-channel-text"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.no.announcements"/></span>

    </td>

   </tr>

  </c:if>

</c:if>

<c:forEach items="${disBean.pgnBean.beans}" var="msgBean" begin="0" end="${disBean.teaserCount - 1}">

  <tr>
 

<c:if test="${disBean.baseURL == 'tag.9c1ec475f7c9df56.render.userLayoutRootNode.target.n267.uP'}">

  <td><span class="uportal-channel-text"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&uP_root=me&selectedId=<c:out value="${msgBean.id}"/>"><font color=red><b><c:out value="${msgBean.subject}"/></b></font></a></span></td>

</c:if>

<c:if test="${disBean.baseURL != 'tag.9c1ec475f7c9df56.render.userLayoutRootNode.target.n267.uP'}">

  <td><span class="uportal-channel-text"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&uP_root=me&selectedId=<c:out value="${msgBean.id}"/>"><c:out value="${msgBean.subject}"/></a></span></td>

</c:if>
 

  </tr>

  <tr><td><img src="/cps/images/misc/dot-blank.gif" height="7" width="1"/></td></tr>

</c:forEach>

<c:if test="${disBean.displayEllipsis}">

  <tr>

    <td><span class="uportal-text-small"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&uP_root=me&selectedId=0"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.more.announcements"><fmt:param><c:out value="${disBean.msgCount}"/></fmt:param></fmt:message></a></span></td>

  </tr>

</c:if>

</table>

</c:when>

<c:otherwise>
 

<table cellpadding="0" cellspacing="0" border="0" width="100%">

  <tr><td colspan="2"><img src="/cps/images/misc/dot-blank.gif" height="7" width="1"/></td></tr>

  <tr>

    <td colspan="2">

    <span class="uportal-channel-text"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.number.of.announcements"><fmt:param><c:out value="${disBean.msgCount}"/></fmt:param></fmt:message></span>

    </td>

  </tr>

  <tr><td colspan="2"><img src="/cps/images/misc/dot-blank.gif" height="7" width="1"/></td></tr>

<c:if test="${disBean.pgnBean.pagesTotal != 1}">

<form action="<c:out value="${disBean.baseURL}"/>" onSubmit="return false">

<input type="hidden" name="detailMode" value="yes"/>

  <tr>

      <td><span class="uportal-text-small"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.displayed.per.page"><fmt:param><c:out value="${disBean.pgnBean.pageSize}"/></fmt:param></fmt:message></span></td>

      <td align="right"><span class="uportal-channel-text">

      <input type="button" value="&nbsp;&lt;&lt;&nbsp;" onClick="form.pageNumber.value=1;form.submit()" class="btn"<c:if test="${disBean.pgnBean.thisPage == 1}"> disabled=""</c:if>/> <input type="button" value="&nbsp;&lt;&nbsp;" onClick="form.pageNumber.value=<c:out value="${disBean.pgnBean.previousPageNumber}"/>;form.submit()" class="btn"<c:if test="${disBean.pgnBean.thisPage == 1}"> disabled=""</c:if>/>

<fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.page.of"><fmt:param><input onChange="form.submit()" size="<c:out value="${disBean.pgnBean.pageNumberWidth}"/>" maxlength="<c:out value="${disBean.pgnBean.pageNumberWidth}"/>" value="<c:out value="${disBean.pgnBean.thisPage}"/>" name="pageNumber" class="uportal-input-text"/></fmt:param><fmt:param><c:out value="${disBean.pgnBean.pagesTotal}"/></fmt:param></fmt:message>

       <input type="button" value="&nbsp;&gt;&nbsp;" onClick="form.pageNumber.value=<c:out value="${disBean.pgnBean.nextPageNumber}"/>;form.submit()" class="btn"<c:if test="${disBean.pgnBean.thisPage == disBean.pgnBean.pagesTotal}"> disabled=""</c:if>/> <input type="button" value="&nbsp;&gt;&gt;&nbsp;" onClick="form.pageNumber.value=<c:out value="${disBean.pgnBean.pagesTotal}"/>;form.submit()" class="btn"<c:if test="${disBean.pgnBean.thisPage == disBean.pgnBean.pagesTotal}"> disabled=""</c:if>/>

      </span></td>

  </tr>

</form>

</c:if>

</table>
 

<table cellpadding="0" cellspacing="0" border="0" width="100%" id="personal_abm_tbl">

<tr>

<td class="uportal-background-content"><img width="1" title="" src="media/org/jasig/portal/channels/CChannelManager/transparent.gif" height="7" alt=""/></td>

</tr>

<tr>

<td class="uportal-background-med"><img width="1" title="" src="media/org/jasig/portal/channels/CChannelManager/transparent.gif" height="1" alt=""/></td>

</tr>

 <tr><td><img src="/cps/images/misc/dot-blank.gif" height="7" width="1"/></td></tr>

</table>
 

<table cellpadding="0" cellspacing="0" border="0" width="100%" id="personal_abm_tbl">

<c:choose>

  <c:when test="${disBean.hasMsgs}">

  <tr>

    <td><span class="uportal-label">&nbsp;</span></td>

    <td><span class="uportal-label"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&sortBy=subject"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.column.header.subject"/></a>&nbsp;<c:choose><c:when test="${disBean.sortBySubject}"><c:choose><c:when test="${disBean.sortOrderD}">&darr;</c:when><c:otherwise>&uarr;</c:otherwise></c:choose></c:when><c:otherwise>&nbsp;</c:otherwise></c:choose>&nbsp; <fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.column.header.details"/></span></td>

    <td><span class="uportal-label"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&sortBy=delivery"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.column.header.delivery.date"/></a>&nbsp;<c:choose><c:when test="${disBean.sortByDelivery}"><c:choose><c:when test="${disBean.sortOrderD}">&darr;</c:when><c:otherwise>&uarr;</c:otherwise></c:choose></c:when><c:otherwise>&nbsp;</c:otherwise></c:choose>&nbsp;</span></td>

    <td><span class="uportal-label"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&sortBy=expiration"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.column.header.expiration.date"/></a>&nbsp;<c:choose><c:when test="${disBean.sortByExpiration}"><c:choose><c:when test="${disBean.sortOrderD}">&darr;</c:when><c:otherwise>&uarr;</c:otherwise></c:choose></c:when><c:otherwise>&nbsp;</c:otherwise></c:choose>&nbsp;</span></td>

    <td><span class="uportal-label"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&sortBy=author"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.column.header.author"/></a>&nbsp;<c:choose><c:when test="${disBean.sortByAuthor}"><c:choose><c:when test="${disBean.sortOrderD}">&darr;</c:when><c:otherwise>&uarr;</c:otherwise></c:choose></c:when><c:otherwise>&nbsp;</c:otherwise></c:choose>&nbsp;</span></td>

  </tr>

<form action="<c:out value="${disBean.baseURL}"/>" onSubmit="return doDelete(this)">

<input type="hidden" name="detailMode" value="yes"/>

<c:forEach items="${disBean.pgnBean.beans}" var="msgBean">

  <tr<c:if test="${disBean.selectedId == msgBean.id}"> class="uportal-background-light"</c:if>>

    <td><input type="checkbox" name="deleteID" value="<c:out value="${msgBean.id}"/>"/></td>

    <td><span class="uportal-text-small"><c:if test="${disBean.selectedId != msgBean.id}"><a href="<c:out value="${disBean.baseURL}"/>?detailMode=yes&selectedId=<c:out value="${msgBean.id}"/>"></c:if><c:out value="${msgBean.subject}"/><c:if test="${disBean.selectedId != msgBean.id}"></a></c:if></span></td>

    <td><span class="uportal-text-small"><c:out value="${msgBean.postDate}"/></span></td>

    <td><span class="uportal-text-small"><c:out value="${msgBean.expDate}"/></span></td>

    <td><span class="uportal-text-small"><c:out value="${msgBean.creatorName}"/></span></td>

   </tr>

  <tr><td colspan="6"><img src="/cps/images/misc/dot-blank.gif" height="7" width="1"/></td></tr>

</c:forEach>

  <tr>

    <td colspan="3"><input value="<fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.column.delete"/>" type="submit" class="btn"/></td>

    <td colspan="3" align="right"><input value="<fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.column.refresh"/>" type="button" onclick="document.location='<c:out value="${disBean.baseURL}"/>?detailMode=yes&Refresh=yes'" class="btn"/></td>

  </tr>

</form>

</c:when>

<c:otherwise>

  <tr><td valign="top"><span class="uportal-channel-text"><strong><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.no.announcements"/>.</strong></td></tr>

  <tr><td><img src="/cps/images/misc/dot-blank.gif" height="7" width="1"/></td></tr>

</c:otherwise>

</c:choose>

</table>
 

<table cellpadding="0" cellspacing="0" border="0" width="100%" id="personal_abm_tbl">

<tr>

<td class="uportal-background-content"><img width="1" title="" src="media/org/jasig/portal/channels/CChannelManager/transparent.gif" height="15" alt=""/></td>

</tr>

<tr>

<td class="uportal-background-med"><img width="1" title="" src="media/org/jasig/portal/channels/CChannelManager/transparent.gif" height="1" alt=""/></td>

</tr>

 <tr><td><img src="/cps/images/misc/dot-blank.gif" height="7" width="1"/></td></tr>

</table>
 

<c:if test="${disBean.annBean.id != 0}">

<table width="100%" class="uportal-background-light" cellspacing="0" cellpadding="10" border="0">

    <tr class="uportal-channel-text">

    <td>

    <span class="uportal-label"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.detail.id"/></span> <span class="uportal-text-small"><c:out value="${disBean.annBean.id}"/></span>

    <br>

    <span class="uportal-label"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.detail.subject"/></span> <span class="uportal-text-small"><c:out value="${disBean.annBean.subject}"/></span>

    <br>

    <span class="uportal-label"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.detail.delivery.date"/></span> <span class="uportal-text-small"><c:out value="${disBean.annBean.delivery}"/></span>

    <br>

    <span class="uportal-label"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.detail.author"/></span> <span class="uportal-text-small"><c:out value="${disBean.annBean.creatorName}"/></span>

    <br>

    <span class="uportal-label"><fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.detail.to"/></span> <span class="uportal-text-small"><c:out value="${disBean.annBean.targetAudience}"/></span>

    </tr>

    <tr>

    <td>

    <table width="100%" class="uportal-background-content" cellspacing="0" cellpadding="2" border="0">

        <tr>

        <td><c:out value="${disBean.annBean.formattedMessage}" escapeXml="false"/></td>

        </tr>

    </table>

    </td>

    </tr>

</table>
 

<table width="100%" cellspacing="0" cellpadding="0" border="0">

<tr>

<td class="uportal-background-content"><img width="1" title="" src="media/org/jasig/portal/channels/CChannelManager/transparent.gif" height="15" alt=""/></td>

</tr>

<tr>

<td class="uportal-background-med"><img width="1" title="" src="media/org/jasig/portal/channels/CChannelManager/transparent.gif" height="1" alt=""/></td>

</tr>

<tr class="uportal-background-light">

<td class="btn" align="right">

    <input value="<fmt:message key="com.sct.pipeline.uportal.channels.announcements.display.detail.delete"/>" type="submit" onclick="doDeleteOne(<c:out value="${disBean.selectedId}"/>)" class="btn"/>

</td>

</tr>

</table>
 

</c:if>
 

</c:otherwise>

</c:choose>

Open in new window

0
Comment
Question by:baumli1
  • 4
  • 4
11 Comments
 
LVL 8

Expert Comment

by:malfunction84
ID: 20403148
Are you including JSTL's standard.jar in your classpath?
0
 

Author Comment

by:baumli1
ID: 20403461
I would assume so, since all the other libraries work except for the functions.

How can I check this?
0
 

Author Comment

by:baumli1
ID: 20403497
in the WEB-INF/lib there is a standard-1.0.4.jar, is this what you are refering to?
0
 

Author Comment

by:baumli1
ID: 20403746
This was at the top of my c.tld file
Does this mean I don't have the correct version to run the functions library?
There wasn't a fn.tld in the folder.
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE taglib

  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"

  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">

<taglib>

  <tlib-version>1.0</tlib-version>

  <jsp-version>1.2</jsp-version>

  <short-name>c</short-name>

  <uri>http://java.sun.com/jstl/core</uri>

  <display-name>JSTL core</display-name>

  <description>JSTL 1.0 core library</description>

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:malfunction84
ID: 20405902
Yeah, your standard-1.0.4.jar should work.

The default version of the JSTL core library does not allow Runtime Expressions such as EL to be passed as parameters to its tags.  Try changing your "core" taglib directive to this:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
0
 

Author Comment

by:baumli1
ID: 20408736
Well, the problem wasn't the c library, the problem was the fn library.  Can you show me what all the libraries will look like?
0
 
LVL 8

Accepted Solution

by:
malfunction84 earned 125 total points
ID: 20409481
Actually, I'm suggesting that the problem may be with the interaction of the "c" and "fn" libraries.  It's a tough call because the only time you use the fn library is when you're passing it into c:set, so I don't know how the fn call acts on its own.

So first things first.  Try using the fn library by itself, outputting the result directly into the page.  (See example 1 below.)

If that doesn't work, we need to re-examine your fn library.  But if it does, we can try examples 2 and 3.

Example 2 uses a special version of the core library which allows you to use EL (the ${...} syntax) in attribute values.  Normally this isn't allowed, which of course makes calling functions impossible.  This is the "interaction" I was referring to before.

If example 2 doesn't work, you can try example 3, which is an alternative way to use c:set to assign values to variables.
<%-- EXAMPLE 1 --%>

<%-- Output the result directly to the page --%>

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

Substring is: ${fn:substring(name2,21,4 )}
 

========
 

<%-- EXAMPLE 2 --%>

<%-- Use a version of the core library that can accept EL as parameters --%>

<%@ taglib prefix="c"  uri="http://java.sun.com/jstl/core_rt" %>

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<c:set var="name3" value="${fn:substring(name2, 21, 4)}" />
 

========
 

<%-- EXAMPLE 3 --%>

<%-- Assign the value using tag content rather than the value attribute --%>

<%@ taglib prefix="c"  uri="http://java.sun.com/jstl/core" %>

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
 

<c:set var="name3">

    ${fn:substring(name2, 21, 4)}

</c:set>

Open in new window

0
 
LVL 27

Assisted Solution

by:rrz
rrz earned 125 total points
ID: 20416825
I think you need to use  JSTL1.1.2  
http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
and  use  
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
0
 
LVL 8

Expert Comment

by:malfunction84
ID: 20417747
Yes, JSTL 1.1.2 should work also.  It accepts RT expressions by default.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
nestparen challenge 4 56
countHi2 challenge 7 44
Problem to start Neon 20 51
Where to store the queries for modification of table 4 26
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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now