Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem creating ArrayList<String>

800306Feb 9 2007 — edited Feb 21 2007
Hi,

I'm new to JSP, so I'm trying to do some basic things, mainly following a JSP tutorial I found online. The tutorial outputted a few numbers to a table, so I decided to try to have it output the values of an ArrayList<String>.

In my file, index.jsp, my code looks like this:
<%@ page import="java.util.*"%> 
<%
ArrayList<String> al = new ArrayList<String>();
al.add("Row 1");
al.add("Row 2");
al.add("Row 3");
al.add("Row 4");
%>

<TABLE BORDER=2>
<%
    for ( int i = 0; i < al.length; i++ ) {
        %>
        <TR>
        <TD>Number</TD>
        <TD><%= al[i] %></TD>
        </TR>
        <%
    }
%>
</TABLE>
When I deploy my page onto my webserver (Tomcat 4.0), I get the following error:
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.


An error occurred between lines: 18 and 24 in the jsp file: /index.jsp

Generated servlet error:
/var/apache/tomcat/work/Standalone/localhost/_/index$jsp.java:85: '(' expected.
                ArrayList<String> al = new ArrayList<String>();
                                                    ^
Forgive me if I missed something obvious, but I'm not sure what the problem is. Where am I missing a parenthesis? What is it talking about? I know the code for creating the ArrayList is correct in Java, so I'm confused as to what the problem is.

If anyone can provide some advice, I'd be appreciative.

Thanks,
Dan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2007
Added on Feb 9 2007
9 comments
168 views