Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”

Use taglib definition in your JSP or better include it in every page by the first line. <%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core” %> There’s also fix jstl-1.2 dependency in your project. Also use servlet specification at least 2.4 in your web.xml. The maven dependencies are (maven is a open source development tool) <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> … Read more

Regular expression to remove special characters in JSTL tags

The JSTL fn:replace() does not use a regular expression based replacement. It’s just an exact charsequence-by-charsequence replacement, exactly like as String#replace() does. JSTL does not offer another EL function for that. You could just homegrow an EL function yourself which delegates to the regex based String#replaceAll(). E.g. package com.example; public final class Functions { private … Read more

java.lang.NumberFormatException: For input string in JSP Page

The ${userRecords} here ${userRecords.user_first_name} ${userRecords.user_middle_name} is a List<User>, however you’re attempting to access it as if it’s a single User. This is not valid. In EL, a List can only be accessed with an integer index, indicating the position of the list item you’d like to access, like so ${userRecords[0].user_first_name} ${userRecords[0].user_middle_name} The exception is also … Read more

JSTL iterate over list of objects

There is a mistake. See this line <c:forEach items=”${myList}” var=”element”>. ${} around ‘myList’ was missing. <c:forEach items=”${myList}” var=”element”> <tr> <td>${element.status}</td> <td>${element.requestType}</td> <td>${element.requestedFor}</td> <td>${element.timeSubmitted}</td> </tr> </c:forEach>

Unicode characters in servlet application are shown as question marks

Seeing ?????? instead of intelligible characters (and even instead of Mojibake) usually indicates that the data transfer responsible is by itself very well aware about the encoding used in both the source and the destination. In the average web application there are only 2 places where this is the case: the point when the data … Read more

Make ${} operator XSS safe in Struts 2 (same as tapestry)

Struts2 <s:property value=”name” /> is automatically escaped by default; JSTL <c:out value=”${name}” /> is automatically escaped by default; JSP EL ${name} is NOT escaped. You can explicitly escape it with ${fn:escapeXml(name)} , or set the escape to be performed by default creating a custom ELResolver as described in this great article: ELResolver Escapes JSP EL … Read more