jstl

Which jstl url should I reference in my jsps?

I'm getting the following error when trying to run a jsp. I'm using Tomcat 6.0.18, and I'd like to use the latest version of jstl. What version of jstl should I use, and which URL goes with which version of jstl? I'm getting this error "According to TLD or attribute directive in tag file, attribute key does not accept any expressions"...

Embedded custom-tag in dynamic content (nested tag) not rendering.

Embedded custom-tag in dynamic content (nested tag) not rendering. I have a page that pulls dynamic content from a javabean and passes the list of objects to a custom tag for processing into html. Within each object is a bunch of html to be output that contains a second custom tag that I would like to also be rendered. The problem is th...

How can I replace newline characters using JSP and JSTL?

I have a list of bean objects passed into my JSP page, and one of them is a comment field. This field may contain newlines, and I want to replace them with semicolons using JSTL, so that the field can be displayed in a text input. I have found one solution, but it's not very elegant. I'll post below as a possibility. ...

How do I get rid of "Cannot resolve property key" in fmt:message tags in JSPs in Intellij

This one has been bugging me for a while now. Is there a way I can stop Intellj IDEA from reporting missing keys in tags? My messages are not stored in property files so the issue does not apply in my case. I'm using IntelliJ IDEA 7.0.4 ...

In JSTL/JSP, given a java.util.Date, how do I find the next day?

On a JSTL/JSP page, I have a java.util.Date object from my application. I need to find the day after the day specified by that object. I can use <jsp:scriptlet> to drop into Java and use java.util.Calendar to do the necessary calculations, but this feels clumsy and inelegant to me. Is there some way to use JSP or JSTL tags to achieve th...

Formatting a long timestamp into a Date with JSTL

I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP. I've created my own tag to do this because I was unable to get the parseDate and formatDate tags to work, but that's not to say they don't work. Any advice? Thanks. ...

test attribute in JSTL <c:if> tag

Hi, I saw some code like the following in a JSP <c:if test="<%=request.isUserInRole(RoleEnum.USER.getCode())%>"> <li>user</li> </c:if> My confusion is over the "=" that appears in the value of the test attribute. My understanding was that anything included within <%= %> is printed to the output, but surely the value assigned to t...

How does jstl's sql tag work?

I'm using the following code to query a database from my jsp, but I'd like to know more about what's happening behind the scenes. These are my two primary questions. Does the tag access the ResultSet directly, or is the query result being stored in a datastructure in memory? When is the connection closed? <%@ taglib prefix="sql" uri=...

JSTL collection iteration

Hi, I have a java bean like this: class Person { int age; String name; } I'd like to iterate over a collection of these beans in a JSP, showing each person in a HTML table row, and in the last row of the table I'd like to show the total of all the ages. The code to generate the table rows will look something like this: <c:forEa...

accessing constants in JSP (without scriptlet)

Hi, I have a class that defines the names of various session attributes, e.g. class Constants { public static final String ATTR_CURRENT_USER = "current.user"; } I would like to use these constants within a JSP to test for the presence of these attributes, something like: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/co...

Access Enum value using EL with JSTL

I have an Enum called Status defined as such: public enum Status { VALID("valid"), OLD("old"); private final String val; Status(String val) { this.val = val; } public String getStatus() { return val; } } I would like to access the value of VALID from a JSTL tag. Specifically the test attri...

Can I use a Hashtable in a unified EL expression on a c:forEach tag using JSF 1.2 with JSP 2.1?

I have a Hashtable<Integer, Sport> called sportMap and a list of sportIds (List<Integer> sportIds) from my backing bean. The Sport object has a List<String> equipmentList. Can I do the following using the unified EL to get the list of equipment for each sport? <h:dataTable value="#{bean.sportIds}" var="_sportId" > <c:forEach items=...

Howto deactivate caching inside a jsp page

I understand there is a HTTP response header directive to disable page caching: Cache-Control:no-cache I can modify the header by "hand": <%response.addHeader("Cache-Control","no-cache");%> But is there a "nice" way to make the JSP interpreter return this header line in the server response? (I checked the <%@page ...%> directive....

How to know if a jsp tag attribute is available for EL ?

I have the following piece of code in my jsp : <% pageContext.setAttribute("warnings",Globals.WARNING_MESSAGES); %> <c:choose> <c:when test="${requestScope[pageScope.warnings] or sessionScope[pageScope.warnings]}"> <html:errors header="warnings.header" footer="warnings.footer" prefix="warnings.prefix" suffix="warnings.suffix"/>...

Enum inside a JSP

Is there a way to use Enum values inside a JSP without using scriptlets. e.g. package com.example; public enum Direction { ASC, DESC } so in the JSP I want to do something like this <c:if test="${foo.direction ==<% com.example.Direction.ASC %>}">... ...

fmt:parseDate - a parse index locale can not be established

Does anyone know the root cause of this error? I am feeding known good data to the fmt:parseDate tag (its db driven data controlled by us), and yet this error randomly pops up. I can't seem to find a way to replicate what causes this exception. ...

Tools to help with Internationalization of Strings in JSP

Are there any tools to assist with the internationalization of Strings within JSP files? Most IDEs (for example, NetBeans) offer such a feature for Java code. However, in the case of NetBeans, no such feature exists for JSP files. With gettext, for example, there is are various tools out there that assist with extracting text Strings f...

How do you get the length of a list in the JSF expression language?

How would I get the length of an ArrayList using a JSF EL expression? "#{MyBean.somelist.length}" does not work. ...

Is it really a best practice to use jstl out tag?

I remember working on a project with a group of developers and they always wanted static html text to be inside of an out tag (<c:out value="words" />). I don't remember why this was the case. Is this really a best practice when building jsp pages? What are the advantages/disadvantages of such an approach? ...

JSTL, Beans, and method calls

I'm working on a JSP where I need to call methods on object that come from a Bean. The previous version of the page does not use JSTL and it works properly. My new version has a set up like this: <jsp:useBean id="pageBean" scope="request" type="com.epicentric.page.website.PageBean" /> <c:set var="pageDividers" value="<%= pageBean.getPag...