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

Does EL support overloaded methods?

EL does not support it, no. It’ll always be the first method of the Class#getMethods() array whose name (and amount of arguments) matches the EL method call. Whether it returns the same method everytime or not depends on the JVM make/version used. Perhaps you made a Java SE upgrade in the meanwhile as well. The … Read more

How can I pass an object to a JSP tag?

A slightly different question that I looked for here: “How do you pass an object to a tag file?” Answer: Use the “type” attribute of the attribute directive: <%@ attribute name=”field” required=”true” type=”com.mycompany.MyClass” %> The type defaults to java.lang.String, so without it you’ll get an error if you try to access object fields saying that … 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

javax.el.PropertyNotFoundException: Property ‘foo’ not found on type com.example.Bean

javax.el.PropertyNotFoundException: Property ‘foo’ not found on type com.example.Bean This literally means that the mentioned class com.example.Bean doesn’t have a public (non-static!) getter method for the mentioned property foo. Note that the field itself is irrelevant here! The public getter method name must start with get, followed by the property name which is capitalized at only … Read more

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