IBM Support

Using Java 5 language feature in a JSP targeting WebSphere Application Server v6.1

Troubleshooting


Problem

WebSphere Application Server (WAS) version 6.1 uses JDK 1.5. By default the JSP's JDK source level still uses JDK 1.3 and this affects how the Java™ compiler compiles the JSP Java sources. Using the default, when the application is deployed on the server, it will fail with error like the following [] JSPG0049E: /admin/stats.jsp failed to compile : JSPG0091E: An error occurred at line: 34 in the file: /admin/stats.jsp JSPG0093E: Generated servlet error from file: /admin/stats.jsp C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\temp\LNGDAYD-4142644 Node01\server1\solrEAR\solr.war\admin\_stats.java : 199 : Syntax error, 'for each' statements are only available if source level is 5.0 JSPG0091E: An error occurred at line: 38 in the file: /admin/stats.jsp JSPG0093E: Generated servlet error from file: /admin/stats.jsp[]

Resolving The Problem

The WAS Information Center specifies that if the application is installed for the first time using the admin console, it gives an option to specify the JDK Source level. Inside Rational Application Developer, they can use the Web Deployment Descriptor Editor.
On the Web Extension tab there is a JSP Attributes table where they can add a new jsp attribute entering jdkSourceLevel as name and 15 as value. This will put an entry to the
Web Project/WEB-INF/ibm-web-ext.xmi
like the following

<jspAttributes xmi:id="JSPAttribute_1" name="jdkSourceLevel"  value="15"/>

[{"Product":{"code":"SSRTLW","label":"Rational Application Developer for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Server Tooling","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF016","label":"Linux"}],"Version":"7.0;7.0.0.1;7.0.0.2;7.0.0.3","Edition":"All Editions","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21264609