Guys i have included jstl and standard.jar in lib directory under classpath. It says absolute uri http://java.sun.com/jstl is not found either in web.xml or in application. please let me know how to configure in websphere 5.1.2
The right taglib URI depends on the JSTL version. Assuming you're using JSTL 1.1 (which would be the best choice for WAS 5.1.2 which runs Servlet 2.3), you need to specify taglib URI's as per this document. So, JSTL core should be specified as follows:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
(note the extra /jsp path; this is added in JSTL 1.1 as opposed to JSTL 1.0)
Related
I have seen a weird problem while using custom tag libraries.
In one of my jsp pages the relative uri path of the custom tld file is wrong.
Taglib is included in jsp page like below
<%# taglib prefix="aaa" uri="WEB-INF/bbb.tld" %>
Location of bbb.tld is : Stores\WebContent\WEB-INF\bbb.tld
This taglib is included in a parent jsp file, and not there jsp file is imported/included from parent.
My application has several other jsp files, where the same taglib is used with the correct path.
The same code is deployed in multiple test environments. In a few environments the code is throwing an error of "Failed to find resource", which is expected. But the taglib is working fine in most of the environments, instead of wrong path.
Why is there discrepancy in the behavior between different server environments? Does the server automatically look for all tld files if the uri can't be resolved?
I would recommend adding a trailing slash ('/') before WEB-INF. Could you try the following?
<%# taglib prefix="aaa" uri="/WEB-INF/bbb.tld" %>
Hopefully, this will give you consistent results across all you server instances. Also, having your TLD in Stores\WebContent\WEB-INF\bbb.tld seems to be related to be using an IDE (e.g. Eclipse) to develop your application. Once you export your application as an EAR or WAR the path will look more like Stores.war/WEB-INF/bbb.tld
(server Tomcat7v)
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
First Name:<c:out value="${param.fname}"></c:out><br/>
Last Name:<c:out value="${param.lname}"></c:out>
in the previous JSP and I am getting
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
this error.
But when I try to find out the jars there were lots of version of that I am confused with which one should I use??
You need to put jstl jar in your classpath. See details at https://stackoverflow.com/tags/jstl/info
I were using Tomcat 7v which uses servlet 3.0 so I had to use jstl1.2.1 jars
I want to use JSTL
I tried to import taglib using:
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
but it says cannot find tag library descriptor for
You can find link to download page in jstl FAQ. Choose the version you need and download necessary dependencies.
I'm having trouble importing the liferay taglibs in one of my JSP pages, no idea what I'm doing wrong. I did the exact same thing in previous projects, but now for some reason it's not working.
My code to import:
<%# taglib uri="http://liferay.com/tld.ui" prefix="liferay-ui" %>
The syntax error I'm getting:
The absolute uri: http://liferay.com/tld.ui cannot be resolved in either web.xml or the jar files deployed with this application
I tried to google this problem quite extensively, but to no avail. The horrible documentation (or lack thereof) for liferay is also not a big help at all.
Thanks in advance for any help!
The taglib URI gets resolved from the following places(in the order):
If the container is Java EE platform compliant, the tag libraries that are part of the Java EE platform. This currently includes JSTL and JSF Tag Library libraries.
Taglib Map in web.xml, the web.xml can include an explicit map of URI's and TLD's respource paths.
TLDs in JAR files in WEB-INF/lib and TLDs under WEB-INF
TLD's supported by Container
In you case, check the following cases:
1) If jar file realted to liferay exists in WEB-INF/lib containing a TLD in jar/META-INF which will be defined with http://liferay.com/tld.ui URI.
2) If there is not jar file and the liferay-ui.tld exists outside the jar file, add the URI mapping entrey in your web.xml like below:
<taglib>
<taglib-uri>http://liferay.com/tld/ui</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location>
</taglib>
it is not
<%# taglib uri="http://liferay.com/tld.ui" prefix="liferay-ui" %>
it should be
<%# taglib prefix="liferay-ui" uri="http://liferay.com/tld/ui" %>
notice that "tld.ui" must be "tld/ui".
liferay-ui.tld comes from util-taglib.jar that liferay adds to your WEB-INF/lib during hot deploy.
No entries to your web.xml are needed.
You probably need to include taglib declaration in your web.xml.
<taglib>
<taglib-uri>http://liferay.com/tld/ui</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location>
</taglib>
As the title says, my JSTL tags don't work on my development server, but do work on Google's actual server.
I simplified the code to the bare bone to make sure there wasn't anything wrong with the code, so here's what I've got.
JSP
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" isELIgnored="false"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Page Title</title>
</head>
<body>
<c:choose>
<c:when test="${2+2==4}">sum works</c:when>
<c:otherwise>sum doesn't work</c:otherwise>
</c:choose>
</body>
My configuration is as follows (which I think is correct and which works on Google's server):
I'm using
Eclipse IDE
Servlet 2.5
No jstl jar added to WEB-INF\lib
No tld added anywhere
No taglib reference
on web.xml
However, I have also tried a number of combinations of the following and none of them worked:
jstl-1.2.jar added to the build path
c.tld added to WEB-INF
taglib reference added to web.xml
Error is below:
HTTP ERROR 500
Problem accessing /index.html. Reason:
javax/servlet/jsp/tagext/TagSupport
Caused by:
java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagSupport
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:927)
at java.lang.ClassLoader.loadClass(ClassLoader.java:298)
at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:87)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:87)
...
Strangely, though, <c:out value="${blah}"/> works both on the development and remote servers. other core tags don't work. If I try to add fmt tags, they don't work as well.
Any ideas?
You need to drop JSTL JAR in /WEB-INF/lib or at least in the /lib folder of the servletcontainer which you're using on local development.
You should not extract the JAR and clutter the webapp with loose TLD files and also not reference it anywhere in web.xml. Undo everything if you have done it. You should also not have the need to manually add it to Eclipse build path. Just dropping in /WEB-INF/lib folder ought to be enough.
See also:
Our JSTL wiki page
The fact that google searches were returning no useful information already indicated that this problem was unique to my configuration.
Alas, I finally managed to figure out what was wrong and I'm just posting the solution in case someone comes across this problem, which dreaded me for days.
Turned out I had added Tomcat's servlet-api.jar and jstl jar into Eclipse's default JRE library to avoid having to add them each time into WEB-INF\lib (i.e. Window > Preferences > Java > Installed JREs > Edit > Add External Jar).
Once I started developing in GAE, this configuration started causing a conflict with AppEngine's own servlet-api.jar and jstl jars.
The answer was simply to remove the Tomcat jars from the JRE library.