how to configure and use jstl in websphere - websphere

Does anybody know how to configure jstl in websphere. i know that we have use taglib directive in web.xml . where do i find web.xml in websphere 5.1.2 and how to add the configuration.

You don't need to modify web.xml at all. Some poor online tutorials indeed suggests that, but you must never take everything at the interwebs for serious. Especially not roseindia.net and consorts.
To install JSTL, all you basically need to do are the following two steps:
Download this file, unzip, browse to /lib and put both jstl.jar and standard.jar in the webapp's runtime classpath.
Declare any of the taglibs as per the JSTL documentation in top of JSP file. For example JSTL core:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
That's all. The default webapp's runtime classpath covers under each Webapp/WEB-INF/lib folder. Just drop the JAR's in there.

Related

Spring taglib in uiBinder xml-file

How can I put my taglib prefix correctly in my name.ui.xml file, is it even possible ?
In an html/jsp file it normally would work with
<%#taglib uri="http://www.springframework.org/tags" prefix="spring"%>
But thats not the case with uiBinder xml files. Is there a way or an alternative ? I'm trying to ensure multilingualism in my application. Thx for any help :)
You do understand that JSP is processed by your server, and UiBinder is processed by the GWT compiler to produce JS for the browser (client), right?
If you want to internationalize your GWT application, there are tools for that: http://www.gwtproject.org/doc/latest/doc/latest/DevGuideI18n.html

How to declare custom taglib in ZK configuration

I have implemented my own custom taglib utility.tld then I put it under the WEB-INF folder and now I want to use it in my web application. This web is developed by ZK framework. I don't know where to declare my taglib utility.tld in the project to let the application understand my taglib definition.
I have tried to put it in web.xml like this:
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/utility.tld</taglib-uri>
<taglib-location>/WEB-INF/utility.tld</taglib-location>
</taglib>
</jsp-config>
But when accessing to the page which uses utility.tld, the server always throws this error: java.io.FileNotFoundException: jndi:/localhost//WEB-INF/utility.tld
Could you please help me how to put this URI declaration to the exact configuration file and what is the correct syntax of this?
By the way, I have found this instruction and followed it, but nothing better happened.
http://books.zkoss.org/wiki/ZUML_Reference/ZUML/Processing_Instructions/taglib/Custom_Taglib
Thank you!
(From the related article)
You can define taglib in two ways:
Put tld file under WebContent, and specify it in zul file with "/PATH/TO/YOUR/TLDFile" directly.
Note the path here starts from WebContent so you can specify it as "/WEB-INF/..."
Put tld file under classpath, and specify it in classpath/metainfo/tld/config.xml with a specific URI, and specify the specific URI in zul file.
Note the path specified in config.xml starts from classpath, the tld file should under the classpath of your web project or in a jar file.
For more information, please refer to the sample project:
TaglibTest

How to share JSP pages in more then one project?

I am trying to find a way to share JSP pages in more then one page?
Example we have the following projects:
commmon
projectA
projectB
The common project has all the CSS, images and two JSP pages. header.jsp and footer.jsp which all the projects in my firm is going to use.
We try adding:
<jsp:include page="/common/webapphead.jsp" />
to projectA and projectB but it still cant find the header, But if I goto
http://127.0.0.1:8080/common/webapphead.jsp
The page does display.
An easy way is to use JSTL. Use the c:import tag.
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:import url="http://127.0.0.1:8080/common/webapphead.jsp" />
Alternatively if you can enable cross context access, then you could use
<c:import url="/webapphead.jsp" context="/common" />
Look at
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Common_Attributes

Spring tags and facelets

Can I use Spring tags with facelets? I have one JSP page, and there is a directive:
<%# taglib prefix="s" uri="http://www.springframework.org/tags"%>
Then I can insert the tag <s:theme code='css' /> (I'm using theme resolver.) Now I need to use theme resolver in another project using facelets instead JSP. There is a namespace declaration instead the JSP directive, isn't?
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:em="http://java.sun.com/jsf/composite/emcomp"
xmlns:st="http://www.springframework.org/tags">
But in Eclipse the namespace is labeled with the warning marker and on server it does not work, because the tag library is missing, althought I have put the library Spring Web MVC in the lib directory of Eclipse Internal Glassfish server. The JAR really contains META-INF/spring.tld.
I'm unable to find, what's wrong.
No, unfortunately you cannot. Spring tags are based on a JSP taglib. Facelet taglibs are different from JSP taglibs. The reason you can use the old-fashioned jsp core tags (c:forEach etc) in facelets is because they have been ported to facelet taglibs. AFAIK, there has not been any port done yet of the Spring JSP taglib to a facelet taglib.

Jasper in Jetty 6 throws exception for JSTL tag

I'm trying to run an application in jetty that runs fine in Tomcat 5.5. The app uses servlet 2.4 and JSP 2.0.
Jetty/Jasper is throwing this exception:
org.apache.jasper.JasperException: /WEB-INF/tiles/layout/main.jsp(85,55) PWC6340: According to the TLD, rtexprvalue is true, and deferred-value is specified for the attribute items of the tag handler org.apache.taglibs.standard.tag.rt.core.ForTokensTag, but the argument for the setter method is not a java.lang.Object
One odd thing, I can't find the TLD anywhere. It seems to be obtaining it by magic that I don't understand. Is it possibly getting a wrong TLD?
It's also hard to tell from where it's loading org.apache.taglibs.standard.tag.rt.core.ForTokensTag. Eclipse doesn't find it in the load path of the project.
Any hints welcome ...
Jetty includes their own JSTL library and there is no need to include jakrta taglib's standard and core jars.
If you do put jakartat taglib's jars into your web application then there is a conflict in the forTokens tag that causes this error while other tags work well. I suggest either remove the jakarta taglib implementation from your web app and rely on Jetty's, or stop using forTokens.
#Guss is correct, the only way out seems to be to avoid the use of c:forTokens.
example alternative to c:forTokens using c:forEach:
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%#taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:forTokens items="${input}" delims="," var="i">
<!-- do stuff with ${i} -->
</c:forTokens>
<c:forEach items="${fn:split(input,',')}" var="i">
<!-- do stuff with ${i} -->
</c:forEach>

Resources