0

It is very easy to create HashMap in jsp using <jsp:useBean> and use it

<jsp:useBean id="abc" class="java.util.HashMap">
    <c:set target="${abc}" property="position" value="triggerBottom"/>
</jsp:useBean>

On other hand, when it comes to ArrayList, it is not that easy. I have seen posts like SOlink1 and SOlink2 where people are using scriplet which bring another problem of using PageContext to get attributes.

I am not able to digest it that HaspMap is so easy to use in jstl but Arraylist is not. Am I missing something? Is there any easy way of creating Arraylist in jsp, without using scriplet, and use el to populate it (as we can do in hashmap).

I am using servlet-3.0 and JSP-2.2.

user811602
  • 1,314
  • 2
  • 17
  • 47
  • Answer depends on Servlet/JSP/EL version. – BalusC Aug 18 '17 at 18:18
  • @BalusC I am using servlet3. Is JSP version/ EL version is different from Servlet version? – user811602 Aug 20 '17 at 13:22
  • Can you upgrade to Servlet 3.1? (which is out for quite some time already btw, e.g. Tomcat 8+, WildFly 8+, GlassFish 4+, etc). It comes with EL 3.0 which natively supports declaring collections via pure EL syntax without need for a legacy jsp:useBean tag. – BalusC Aug 20 '17 at 13:43
  • @BalusC for me it is not possible to upgrade to Servlet 3.1. I am part of much bigger team. Tomcat Version : Apache Tomcat/7.0.68 Servlet Specification Version : 3.0 JSP version : 2.2 is what we are using. Is there any nice way to use Arraylist without scriplet? – user811602 Aug 20 '17 at 14:45

0 Answers0