wood burning stoves 2.0*
The moose likes JSP and the fly likes Problem in jsp while using generics. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem in jsp while using generics." Watch "Problem in jsp while using generics." New topic

Problem in jsp while using generics.

vikky agrawal
Ranch Hand

Joined: Dec 18, 2008
Posts: 65
Hello all,
while writing a jsp page i faced a problem using generics.

the error is:

ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 9 in the jsp file: /test.jsp
Generated servlet error:
Syntax error on token "<", invalid AssignmentOperator

An error occurred at line: 9 in the jsp file: /test.jsp
Generated servlet error:
Syntax error on token "=", != expected

An error occurred at line: 9 in the jsp file: /test.jsp
Generated servlet error:
Syntax error on token "<", ( expected

An error occurred at line: 9 in the jsp file: /test.jsp
Generated servlet error:
Syntax error on token "(", invalid Expression

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)

when i removed generic syntax from Arraylist then the code works fine.
why this error and how to remove it.

scjp 6
Andrey Choe

Joined: Sep 07, 2010
Posts: 12
Hello vikky,
are you sure that you are using jdk 1.5 or above?
Your code works fine on jdk 1.6.16 (sun), tomcat 6.0.20

Michael Houlo
Ranch Hand

Joined: Jun 07, 2010
Posts: 58
Indeed, looks like you're not using java 1.5+

Just so you know, using scriplet in a jsp file is not a good practice.
You better use something like jstl
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61084

Java code (scriptlets) in a JSP have been discredited for over 8 years now. It's long past time to stop writing JSPs like it's 2002.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem in jsp while using generics.