Reputation: 4408
From Java Class set the value in the bellow map ans set it within request.
Map<String,String> responseMap = new LinkedHashMap<String, String>();
responseMap.put("requestId", "test");
request.setAttribute("nomineeResponseMap", responseMap);
Now I am trying to get this request from the jsp page but unable to get data from this Map.
Below code which I used in JSP page.
From JSP Page:
Object responseMap = request.getAttribute("nomineeResponseMap");
if(responseMap instanceof LinkedHashMap) {
Map<String, String> newMap = (LinkedHashMap) responseMap;
System.out.println("yesss");
}
Below Exception I am getting while running the program:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 36 in the jsp file: /form/EDCPRequestSuccess.jsp
Generated servlet error:
The type Map is not generic; it cannot be parameterized with arguments <String, String>
An error occurred at line: 36 in the jsp file: /form/EDCPRequestSuccess.jsp
Generated servlet error:
Syntax error, parameterized types are only available if source level is 5.0
Why I am getting the above exception?
Upvotes: 0
Views: 335
Reputation: 3024
If your server is running using JDK 1.5 or higher version. The issue is caused by wrong JSP compiler setting.
For Tomcat server, the setting could be found in $TOMCAT_HOME/conf/web.xml
. The error is throwed if compilerSourceVM
and compilerTargetVM
are set to 1.4 or lower version.
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.4</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.4</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
Upvotes: 1
Reputation: 133
Please check your JFK version, I think you are using less than jdk1.5
Upvotes: 0