Creating Array using JSTL or EL

If you’re already on EL 3.0 (Tomcat 8+, WildFly 8+, GlassFish 4+, Payara 4+, TomEE 7+, etc), which supports new operations on collection objects, you can use ${[…]} syntax to construct a list, and ${{…}} syntax to construct a set. <c:set var=”alphabet” value=”${[‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’]}” scope=”application” /> If you’re not on EL 3.0 yet, use the ${fn:split()} … Read more

How to install JSTL? It fails with “The absolute uri cannot be resolved” or “Unable to find taglib” or NoClassDefFoundError or ClassCastException

In your specific case, org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application that URI is for JSTL 1.0, but you’re actually using JSTL 1.2 which uses URIs with an additional /jsp path. This URI change is because JSTL, who invented EL expressions, was since … Read more

JSTL Sets and Lists – checking if item exists in a Set

You could do this using JSTL tags, but the result is not optimal: <%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%> <html> <body> <jsp:useBean id=”numbers” class=”java.util.HashSet” scope=”request”> <% numbers.add(“one”); numbers.add(“two”); numbers.add(“three”); %> </jsp:useBean> <c:forEach items=”${numbers}” var=”value”> <c:if test=”${value == ‘two’}”> <c:set var=”found” value=”true” scope=”request” /> </c:if> </c:forEach> ${found} </body> </html> A better way would be to use a custom … Read more

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

View all fields / properties of bean in JSP / JSTL

Replace object with the bean to determine. <c:set var=”object” value=”${product}” /> Display all declared fields and their values. <c:if test=”${not empty object[‘class’].declaredFields}”> <h2>Declared fields <em>&dollar;{object.name}</em></h2> <ul> <c:forEach var=”field” items=”${object[‘class’].declaredFields}”> <c:catch><li><span style=”font-weight: bold”> ${field.name}: </span>${object[field.name]}</li> </c:catch> </c:forEach> </ul> </c:if> Display all declared methods. <c:if test=”${not empty object[‘class’].declaredMethods}”> <h2>Declared methods<em>&lt;% object.getName() %&gt;</em></h2> <ul> <c:forEach var=”method” items=”${object[‘class’].declaredMethods}”> <c:catch><li>${method.name}</li></c:catch> … Read more

How to obtain request / session / servletcontext attribute in JSP using EL?

It’s just the attribute name as you’ve set yourself here: request.setAttribute(“list”, fooList); It’s thus “list”: ${list} This works the same way for session.setAttribute(“name”, value) and application.setAttribute(“name”, value). The value is in EL available by just ${name}. More detail: EL uses by default PageContext#findAttribute() which scans in subsequently the page, request, session and application scopes for … Read more

How to encode a String representing URL path with JSTL?

The <c:url> does not encode the URI as specified in its value, but just URL request parameters which are specified by a nested <c:param>. The IBM article which you linked also doesn’t tell otherwise. I think that you confused it with “URL rewriting” (which is in essence nothing more than appending the jsessionid whenever necessary). … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)