I have the following code which shows some products in a combobox
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
List<String> productos = new ArrayList<>();
productos.add("TV");
productos.add("PC");
productos.add("Stereo");
productos.add("Iphone");
%>
<select>
<%
for (String p : productos)
{
out.println("<option>" + p + "</option>");
}
%>
</select>
</body>
</html>
But when I run it I get the following error
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP PWC6199: Generated servlet error: source value 1.5 is obsolete and will be removed in a future release PWC6199: Generated servlet error: target value 1.5 is obsolete and will be removed in a future release PWC6199: Generated servlet error: To suppress warnings about obsolete options, use -Xlint:-options. PWC6197: An error occurred at line: 17 in the jsp file: /index.jsp PWC6199: Generated servlet error: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)<
I have version 8 of Java, version 4.1.1 of Glassfish and the latest version of Netbeans.
You probably use Java 5 but the diamond operator <> is the Java 7 feature. So there are two solutions:
Upgrade to Java 7 Don't use the diamond operator <>
Instead of declaring ArrayList like this:
Declare ArrayList Like
i.e. don't use the <> on the right hand side