• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Generics in scriptlets  RSS feed

 
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!