[Logo]
Forums Register Login
Generics in scriptlets
Hello ranchers,

this does not work in a scriptlet in a JSP:

<%
SortedMap<String, Integer> map = new TreeMap<String, Integer>();
%>

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token "<", ( expected

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error, insert ")" to complete Expression

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token "<", ( expected

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token "(", invalid Expression


This does not work, too:

<%
SortedMap & l t ; String, Integer & g t ; map = new TreeMap & l t ; String, Integer & g t ; ();
%>

The blanks between & l t ; and & g t ; are only to display the code in this thread.
In my JSP there are no blanks.

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token "&", invalid AssignmentOperator

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token ",", invalid AssignmentOperator

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token "new", delete this token

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token ",", invalid AssignmentOperator

An error occurred at line: 36 in the jsp file: /WEB-INF/prodList.jsp
Generated servlet error:
Syntax error on token ";", this expected after this token


How can I work with generics in scriptlets?


Regards,
Oliver
Just donĀ“t use scriptlets at all. Java code belongs in Java classes, not in JSP files. Make use of servlets, beans, DAO and/or utility classes.

To control output and flow in JSP, just use taglibs (JSTL, JSF, etc) and EL the usual way.

This thread has been viewed 1927 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 26, 2018 08:17:14.