3 Replies Latest reply on Feb 1, 2008 6:01 AM by bvogt

    jsp static import

    creatureoflegend

      I think I may have posted this in the wrong forum earlier:

      I'm trying to use static imports, but running into a problem in jsps. The following doesn't work:

      <%@page import="static package.name.ClassName.*"%>

      I am getting the following:

      org.apache.jasper.JasperException: Unable to compile class for JSP

      Generated servlet error:
      Syntax error on token "static", delete this token

      Then it tells me that the variable I'm importing cannot be resolved.

      I am using JBoss version 4.0.3SP1 and it's target JDK is 1.6

      Does Jboss not support jsp static imports?

        • 1. Re: jsp static import
          jaikiran

           

          I am using JBoss version 4.0.3SP1


          I guess, you wont be able to achieve this in JBoss 4.0.3. Starting JBoss4.0.4GA, a compilerSourceVM parameter is made available for JSP compiler. This parameter can be set in the conf/web.xml folder present in %JBOSS_HOME%\server\< serverName>\deploy\jbossweb-tomcat55.sar folder. This web.xml contains the following:

          <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>
           <!-- Uncomment to use jdk1.5 features in jsp pages
           <init-param>
           <param-name>compilerSourceVM</param-name>
           <param-value>1.5</param-value>
           </init-param>
           -->


          Uncommenting that portion is enough and you will be able to compile that JSP without any problems. This parameter is not available for 4.0.3, so you might have to upgrade to a later version of JBoss.

          By the way, for using static imports you dont have to use JDK6. Static imports were introduced in Java 5 : http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#static_import



          • 2. Re: jsp static import
            creatureoflegend

            Cool. Thank you very much! :)

            • 3. Re: jsp static import
              bvogt

              just an update for AS 4.2.0 (current users of RH Application Stack):

              although the comment in web.xml states:

              <!-- compilerTargetVM Compiler target VM -->
               <!-- default is System.properties -->
               <!-- java.specification.version > 1.4 -->
               <!-- [1.5] else [1.4] -->
               <!-- -->
               <!-- compilerSourceVM Compiler source VM -->
               <!-- default is System.properties -->
               <!-- java.specification.version > 1.4 -->
               <!-- [1.5] else [1.4] -->
              

              and boot.log reports:
              11:43:27,272 DEBUG [ServerInfo] java.specification.version: 1.5

              the <init-param> definition below has to be added in order to successfully compile 1.5 jsps