fn:length cannot be found: org.apache.taglibs.standard.functions.Functions - jstl

I have included tag library in jsp as mentioned below:
<%# taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
And I am trying to use it in this code:
<c:when test="${fn:length(training.trainingevents) gt 0 }">
But getting below error
org.apache.jasper.JasperException: The class org.apache.taglibs.standard.functions.Functions specified in TLD for the function fn:length cannot be found: org.apache.taglibs.standard.functions.Functions

Not sure, about the error of jstl tag library, but I could solve the problem by using below code,
<c:when test="${not empty training.trainingevents}">

Error has occurred due to older jar of JSTL, use JSTL 1.2 version to resolve the issue. It worked for me.

Related

How/Can I include secondary files into a file during gradle's expand/copy?

I am trying to template various XML files. What I want to do is be able to build out a Parent XML by including several Child XML files. This should happen during the expand()->copy() using the SimpleTemplateEngine
as an example:
Gradle:
processResources {
exclude '**/somedir/*'
propList.DESCRIPTION = 'a description goes here'
expand(propList)
}
Parent.XML:
<xml>
<line1>something</line1>
<%include file="Child.XML" %>
</xml>
The documentation states that the SimpleTemplateEngine uses JSP <% syntax and <%= expressions, but does not necessarily provide a list of supported functions.
include fails with it not being a valid method on the resulting SimpleTemplateScript, maybe I meant eval?
The closest I've come to getting something to work is:
<xml>
<line1>something</line1>
<% evaluate(new File("Child.xml")) %>
</xml>
That results in 404 of the Child.xml as it's looking at the process working directory, rather than that of the Parent file. If I reference it as "build/resources/main/templates..../Child.xml", then I get 'unexpected token: < # line....' errors from parsing the Child.
Can this be done? Do I need to change template engines, if that's even possible? Ideally it should process any tokens in Child as well.
This is all very simple in JSP. I somehow got the impression I can treat these files like they're GSP, but I'm not sure how to properly use the GSP tags, if that's even true.
Any help, as always, is greatly appreciated.
Thank you.
This documentation doesn't mention JSP. The syntax for the SimpleTemplateEngine is ${}.
Using Gradle 3.4-rc2, if I have this build.gradle file:
task go(type: ProcessResources) {
from('in') {
include 'root.xml'
}
into 'out'
def props = [:]
props."DESCRIPTION" = "description"
expand(props)
}
where in/root.xml is:
<doc>
<name>root</name>
<desc>${DESCRIPTION}</desc>
${new File("in/childA.xml").getText()}
</doc>
and in/childA.xml is:
<child>
<name>A</name>
</child>
then the output is:
<doc>
<name>root</name>
<desc>description</desc>
<child>
<name>A</name>
</child>
</doc>

Can not find the tag library descriptor for "http://www.day.com/taglibs/cq/personalization/1.0

While setting up AEM 6.1 plugin in eclipse and importing all the contents from crx got the following error under /libs/foundation/components.
Can not find the tag library descriptor for "http://www.day.com/taglibs/cq/personalization/1.0
Code:
<%#taglib prefix="personalization" uri="http://www.day.com/taglibs/cq/personalization/1.0" %>

Webpage can not access jar for applet

I created two maven project: project-applet and project-webapp.
The java applet works fine: I can start it with the applet-viewer in a static html file with the necessary applet-tag.
Now I'm trying to move this static html file into a servlet (actually just it's content) index.jsp
<html>
<body>
<applet
code="project.applet.Applet.class"
codebase="/lib"
archive="project-applet-0.1.0.BUILD-SNAPSHOT.jar" width="900"
height="300"> Your browser is completely ignoring the applet tag! </applet>
</body>
</html>
I'm building everything with maven. The project-applet-0.1.0.BUILD-SNAPSHOT.jar is in the project-webapp-0.1.0.BUILD-SNAPSHOT.war file in this position WEB-INF/lib/.
I also tried to just copy it to project-webapp/src/main/webapp/ with codebase="/" but this didn't help even if the jar can be download from localhost:8080/project-webapp/project-applet-0.1.0.BUILD-SNAPSHOT.jar.
Can someone help me?
Thanks!
If the jar is lying at localhost:8080/project-webapp/project-applet-0.1.0.BUILD-SNAPSHOT.jar, the codebase is like this codebase="/project-webapp/"

how to access my custom jsp taglib in STS 4.3?

I have a Spring MVC web app whic I'm developing using the STS 4.3 as my IDE.
I decided to try my hand on custom JSP tag libraries.
These are the tutorial I'm following: http://www.tutorialspoint.com/jsp/jsp_custom_tags.htm and http://www.noppanit.com/how-to-create-a-custom-function-for-jstl/ and http://blog.denevell.org/tomcat7-el-custom-function.html and many other links (too many to list but similar in content).
I have configured Tomcat7 as my testing server from with STS 4.3
I have created a new project in STS and called it "MyCustomUtilities".
folder structure of MyCustomUtilities project: http://i.imgur.com/9nEuPYW.jpg
source code for MyCustomUtilities.java
package org.flinders.mycustomutilities;
import java.lang.StringBuilder;
public class MyCustomUtilities {
public static String StringToHTML(String inputString) {
StringBuilder returnString = new StringBuilder();
char[] inputChar = inputString.toCharArray();
for (char c: inputChar) {
returnString.append("&#").append((int) c).append(";");
}
return returnString.toString();
}
}
JSP snippet (I've also tried <%# taglib uri="WEB-INF/MyCustomUtilities.tld" prefix="mine" %> but still getting error)
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# taglib uri="http://localhost:8080/MyCustomUtilities.tld" prefix="mine" %>
Tomcat folder structure: http://i.imgur.com/oT3Ndhp.jpg
I have created a system variable called "CLASSPATH" and it's pointing to the ROOT/WEB-INF (full path of course. just shorten it here).
here's my TLD file (unsure on what to put on the uri portion but I'm accessing my web app on localhost:8080 on my browser)
<?xml version="1.0" encoding="ISO-8859-1" ?>
<taglib 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/web-jsptaglibrary_2_0.xsd"
version="2.1">
<tlib-version>2.0</tlib-version>
<uri>localhost:8080/MyCustomUtilities</uri>
<function>
<name>StringToHTML</name>
<function-class>org.flinders.mycustomutilties.MyCustomUtilities</function-class>
<function-signature>java.lang.String StringToHTML(java.lang.String)</function-signature>
</function>
</taglib>
Any ideas on how can I setup/configured tomcat/STS so it can see my custom tag library? As I said above, I'm looked at various examples but they don't seem complete. thanks

javax.el.ELContext cannot be resolved error when adding FaceletContext jsf maven built

I have this error when I added those lines in one method of managed bean :
I fixed the imports of my project but no result
I use maven spring jsf and hibernate
here is the error :
Unresolved compilation problem: The type javax.el.ELContext cannot be resolved. It is indirectly referenced from required .class files
here the lines that causes error :
FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
String formId = (String) faceletContext.getAttribute("hiddenIds");
do you have any idea
I also got the same error and resolved the issue by adding el-api-2.2 jar which contains the javax.el.ELContext class. The reason for the above error was javax.faces.view.facelets.FaceletContext class was internally calling the javax.el.ELContext class.

Resources