If your needs are simple for the bean, then you can just add code directly to your JSP. To see what I mean, look at the Servlet that was generated from your JSP. Every JSP is translated to a Servlet. For example, consider the following JSP.
<jsp:useBean id="myList" class="java.util.ArrayList"/>
${myList.add("My first element")}
<%myList.add("My second element");%>
${myList}
The translation(in Tomcat's work folder) is
java.util.ArrayList myList = null;
myList = (java.util.ArrayList) _jspx_page_context.getAttribute("myList", jakarta.servlet.jsp.PageContext.PAGE_SCOPE);
if (myList == null){
myList = new java.util.ArrayList();
_jspx_page_context.setAttribute("myList", myList, jakarta.servlet.jsp.PageContext.PAGE_SCOPE);
}
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${myList.add(\"My first element\")}", java.lang.String.class, (jakarta.servlet.jsp.PageContext)_jspx_page_context, null));
myList.add("My second element");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${myList}", java.lang.String.class, (jakarta.servlet.jsp.PageContext)_jspx_page_context, null));
The useBean action tag just creates a scripting variable and sets a scoped variable. You can do that without any special tag. The following JSP does the same thing.
<%@ page import="java.util.ArrayList"%>
<%
ArrayList myList2 = new ArrayList();
myList2.add("one");
pageContext.setAttribute("myList2", myList2);
%>
${myList2}
<%=myList2%>