Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:27:46+00:00 2026-05-24T19:27:46+00:00

I want to implement custom JSP list tag, but have problem with accessing properties

  • 0

I want to implement custom JSP list tag, but have problem with accessing properties of custom list object. With example like below accessing a name property of List2 on test.jsp page give an error org.apache.jasper.JasperException: java.lang.NumberFormatException: For input string: "name". How to solve this ?

public class List2 extends ArrayList<String> {

    public String getName() {
        return "name";
    }
}

test.jsp

<%-- java.lang.NumberFormatException --%>
${list.name}

<%-- this works ok --%>
<c:forEach  items="${list}" var="item">
   ${item}  
</c:forEach>

EDIT

Whole test.jsp working

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:forEach  items="${list}" var="item">
   ${item}
</c:forEach>

Whole test.jsp NOT working

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
${list.name} 

TestController.java:

@Controller
public class TestController {

    @ModelAttribute("list")
    public List2 testList() {
        List2 l = new List2();
        l.add("foo");
        l.add("bar");
        return l;
    }

    /* test.jsp */
    @RequestMapping("/test")
    public String test() {
        return "test";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:27:47+00:00Added an answer on May 24, 2026 at 7:27 pm

    I think it’s due to the fact that the JSP EL allows using . or [] to access object properties. But both have a special meaning for List instances: it means access to the nth element. You may thus write ${list[2]} or ${list.2}. Since EL detects that your object is an instance of a collection, it tries to transform name into a number, and you get this exception.

    Note that this is only an explanation of the exception you get. I haven’t checked the specification to see if it’s a bug of Tomcat or if it’s expected behavior.

    You should very very rarely extend ArrayList. Most of the time, it’s better to use delegation, and thus wrap the list inside another object. Couldn’t you just have something like the following?

    public class List2 {
    
        private List list;
    
        public String getName() {
            return "name";
        }
    
        public List getList() {
            return list;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement a custom scrollbar but want it to work like the
I want to implement a custom assembly signature mechanism just like Strong Name, then
I want to implement a custom trace listener like follows: public class TraceListener :
I'm trying to implement a DataGrid in ASP.NET, and want to achieve custom paging
I want to implement an ISAPI filter like feature using HttpModule in IIS7 running
I want to store JSP session data in a custom store (the one I
I want to implement a Custom logger which logs all log entries to a
I am new to Flex programming. I want to implement a custom toolstrip for
I want to implement a custom user authentication system in my appengine app. I
Suppose I have a namedtuple like this: EdgeBase = namedtuple(EdgeBase, left, right) I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.