Netbeans will not treat JSP as Source Level 7

一曲冷凌霜 提交于 2019-12-03 21:08:02

问题


I'm trying to run a .jsp page I made and keep encountering this error:

type Exception report

message Internal Server Error

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197: An error occurred at line: 27 in the jsp file: /Drupalcheck.jsp PWC6199: Generated servlet error: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.

The issue is that I have no clue why I'm getting it. I have the JDK set to 1.7 under Libraries and Source/Binary Format set to JDK 7 under sources.

I am using Netbeans as my IDE.

I've done everything from reinstalling Java to reinstalling Netbeans and have gotten nowhere.


回答1:


In my opinion this has nothing to do with Netbeans, but rather with the application server in use. Is suspect you're using Glassfish or Tomcat as they are bundled together with Netbeans 7.

I had the same problem with Apache Tomcat and it boiled down to that Tomcat (Apache Jasper library) is using Java 1.6 for JSP compilation by default. You'll have to change the default configuration of the JSP servlet in web.xml. I added the following lines to the application's web.xml, note the two parameters compilerSourceVM and compilerTargetVM:

<!-- Jasper JSP configuration -->
<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>fork</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>xpoweredBy</param-name>
        <param-value>false</param-value>
    </init-param>
    <init-param>
        <param-name>compilerSourceVM</param-name>
        <param-value>1.7</param-value>
    </init-param>
    <init-param>
        <param-name>compilerTargetVM</param-name>
        <param-value>1.7</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

<!-- The mappings for the JSP servlet -->
<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    <url-pattern>*.jspx</url-pattern>
</servlet-mapping>


来源:https://stackoverflow.com/questions/19674097/netbeans-will-not-treat-jsp-as-source-level-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!