Topic: JSP 2.0
Application Server: JBoss 4.0.2 / Tomcat 5.5.9
Exception:
An error occurred at line: 8 in the jsp file: /Test.jsp Generated servlet error: Syntax error, insert ")" to complete Expression An error occurred at line: 8 in the jsp file: /Test.jsp Generated servlet error: Syntax error on token ")", delete this token org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:810) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
Resolution:
The JSP Expression opening tag starts with the sequence '<%=' – the contents of the JSP Expression must always evaluate to a value (the return from the code within a JSP Expression should not be a void) and there should be no semi-colon or multiple program statements within the code. This is because the contents of a JSP Expression become an argument to the out.println() method after translation. For example,
<%= (String)request.getAttribute("abcd") %> gets translated to the following Java code:
out.println((String)request.getAttribute("abcd"));
Removal of the semi-colon or multiple program statements from within the JSP Expression will eliminate this exception.
No comments:
Post a Comment