jstl

Importing the content of another web resource using JSTL

I have a JSP page that will display the exact content of another web page on a different server. My understanding was that c:import from the JSTL should be able to include content from files that are not part of the current web application. I added c:import url="page on my server in a different application" and it works fine, but when ...

How to alternate HTML table row colors using JSP?

How do I alternate HTML table row colors using JSP? My CSS looks something like: tr.odd {background-color: #EEDDEE} tr.even {background-color: #EEEEDD} I want to use <c:forEach> to iterate over a collection. <c:forEach items="${element}" var="myCollection"> <tr> <td><c:out value="${element.field}"/></td> ... </tr> </c:f...

JSTL forEach tag: problems with enumeration, and with understanding how it should work

Hello, I've experienced rather strange behavior of JSTL forEach tag. I have some bean called SessionBean: public class SessionBean { private Collection<MyObject> objects; public Collection<MyObject> getObjects() {return objects;} ... } And a simple JSP page like that: <%@page contentType="text/html"%> <%@page pageEncoding="UTF...

How do I get rid of TagExtraInfo JSTL warning in Eclipse?

I'm working with JSTL in Eclipse, using the WTP. I have jstl and standard.jar in my WEB-INF/lib directory, and everything works. Eclipse is giving me this warning in my JSP: The TagExtraInfo class for c:forEach (org.apache.taglibs.standard.tei.ForEachTEI) was not found on the build path. I have JSTL included: <%@ taglib uri="http://...

Format Date with fmt:formatDate JSP

I am trying to format a date with: <fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/> newsletter is an object with a createdOn property which is java.util.Date. When I invoke the previous sentence I get: According to the TLD, the attribute value does not accept expressions. I am importing fmt with <%@ tag...

JSP <c:out> tag

Writing a JSP page, what exactly does the <c:out> do? I've noticed that the following both has the same result: <p>The person's name is <c:out value="${person.name}" /></p> <p>The person's name is ${person.name}</p> ...

Where can I download JSTL jar

Does anyone know because all the places I've tried seem to timeout! ...

trimming a string in a JSTL expression

I have the following line in a JSP page: <c:if test="${postAuditBean.postAudit.authority == authority.value}"> I would like change this comparison to first trim leading and trailing spaces from both the left and right hand expressions prior to comparison... as in something like this: <c:if test="${trim(postAuditBean.postAudit.authori...

Access JSTL tag from code inside of forEach loop

Is it possible to access JSTL's forEach variable via code from within the loop? <c:forEach items="${elements}" var="element"> <% element.someMethod(); %> </c:forEach> ...

What are the alternatives to JSTL?

Are there any alternatives to JSTL? One company I worked for 3 years ago used JSTL and custom tag libraries to separate presentation from logic. Front-end developers used EL to do complex presentation logic, generate layouts in JSP pages and it worked out great. Perhaps new technologies have come out. Anything better these days? ...

In Spring/JSP, where should formatting be performed?

I'm using Spring, but this question applies to all JSP-controller type designs. The JSP page references data (using tags) which is populated by the corresponding controller. My question is, where is the appropriate place to perform formatting, in JSP or the controller? So far I've been preparing the data by formatting it in my controll...

Error using JSTL XML taglib - attribute xml does not accept any expressions

I'm getting the following error when I try to use the JSTL XML taglib: /server-side-transform.jsp(51,0) According to TLD or attribute directive in tag file, attribute xml does not accept any expressions I'm looking into the tlds etc, but if anyone knows what this is an can save me some time, it'd be appreciated! If it helps, I get t...

JSTL Printing arrayList elements

I have a JSP page that receives an ArrayList of event objects, each event object contains an ArrayList of dates. I am iterating through the event objects with the following: How can I iterate through the dateTimes ArrayList of each event object and print out each events date/times ? ...

How do I make a Java ResultSet available in my jsp?

I'd like to swap out an sql:query for some Java code that builds a complex query with several parameters. The current sql is a simple select. <sql:query var="result" dataSource="${dSource}" sql="select * from TABLE "> </sql:query> How do I take my Java ResultSet (ie. rs = stmt.executeQuery(sql);) and make the results availa...

How to create hyperlink in Spring + JSP

What's the proper way to create a hyperlink in Spring+JSP? There must be a better way than just coding in the <a href="..."> tag. Take for example a page that displays people. The URL is people.htm. The corresponding controller gets people from the database and performs optional column sorting. The JSP might look like: <table> <tr> <t...

Showing the current date using JSTL formatDate tag

I am trying to show the current date in my JSP page using JSTL. below is the code I am using. <jsp:useBean id="now" class="java.util.Date" scope="request" /> <fmt:formatDate value="${now}" pattern="MM.dd.yyyy" /> But the above code is not producing any results? Am I missing anything here or is there any better approach for this? I am ...

Spring MVC tag interaction with custom tag

I have a JSP that is using Spring:form tags to bind controls to a command object. I would like to modify it as follows: if [some condition is true] than display the controls; otherwise, just display the text. (Examples: if the user is an Admin, display the controls, otherwise just display the text. If the whatsit is still open for modi...

JSTL Exception while comparing a string

I have the next code in a JSTL file: <c:choose> <c:when test="${application.lodging eq 'F'}"><bean:message key="courseapplication.lodgingF"/></c:when> <c:when test="${application.lodging eq 'H'}"><bean:message key="courseapplication.lodgingH"/></c:when> <c:when test="${application.lodging eq 'B'}"><bean:message key="coursea...

How do I dynamically access request parameters with JSP EL?

I'm looping through a list of items, and I'd like to get a request parameter based on the item's index. I could easily do it with a scriptlet as done below, but I'd like to use expression language. <c:forEach var="item" items="${list}" varStatus="count"> <!-- This would work --> <%=request.getParameter("item_" + count.index)%> ...

JSTL and authenticated web services

Can I access an authenticated web service using JSTL? (Form-based authentication) If I can't do it using JSTL, is there any other way I do it from a JSP? Maybe I need to give a little more information. I'm using the core library: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> and the import tag, as in: <c:import ...