Precompiling JSP pages

876 Views Asked by At

Sorry for my English.

I’m trying to precompile JSP files with ANT script. With this I generated servlets from JSP:

<target name="jspc">
    <taskdef classname="org.apache.jasper.JspC" name="jasper2">
        <classpath id="jspc.classpath">
            <pathelement location="C:\j2sdk1.4.2_12\lib\org.apache.jasper.jar" />
            <path refid="jbossweb.classpath"/>
        </classpath>
    </taskdef>

    <jasper2 validateXml="false" uriroot="${webapp.path}" package="org.fista.zg.ui.struts.pages"
        webXmlFragment="c:/generated_web.xml" outputDir="${webapp.path}/WEB-INF/src" />
</target>

So, now I have Servlet classes, and I want compile these classes. Some classes have been compiled successfully, but some not, many of unsuccessfully compiled pages thrown same error, for example:

[javac] C:\Documents and Settings\Administrator\workspace\web-admin\WebContent\WEB-INF\src\agencyDelete_jsp.java:79: cannot resolve symbol
[javac] symbol  : variable actionForm 
[javac] location: class org.fista.zg.ui.struts.pages.agencyDelete_jsp
[javac]         new Object[] {((AgencyInputForm)((DefaultInputActionForm)actionForm).getFormBean()).getContractNr()});
[javac]                                                                          ^

In JSP agencyDelete.jsp:

<bean:define id="actionForm" name="AgencyForm" />
<%
    String message = WebCtrlFactory.getCtrl(request).getLocalizationString("org.fista.zg.ui.struts.agency.remove",
        new Object[] {((AgencyInputForm)((DefaultInputActionForm)actionForm).getFormBean()).getContractNr()});
%>

Ant compiling script:

<javac destdir="${webapp.path}/WEB-INF/classes" optimize="off" debug="on"
            failonerror="false" srcdir="${webapp.path}/WEB-INF/src" excludes="**/*.smap"
            classpath="C:\Documents and Settings\Administrator\workspace\web-admin\build\classes">
    <classpath>
        <fileset dir="${webapp.path}/WEB-INF/lib">
            <include name="*.jar" />
        </fileset>
        <path refid="jbossweb.classpath"/>
    </classpath>
    <include name="**" />
    <exclude name="tags/**" />
    <exclude name="tiles/**" />
</javac>

So, please help me find the problem. I think problem is in: “<bean:define id="actionForm" name="AgencyForm" />”. Why compiler can't see this bean?

1

There are 1 best solutions below

1
On

Correct way to access "actionForm" bean (page scope variable) inside JSP Scriptlet is

<%
String message = WebCtrlFactory.getCtrl(request).getLocalizationString("org.fista.zg.ui.struts.agency.remove",
new Object[] {((AgencyInputForm)    ((DefaultInputActionForm)pageContext.getAttribute("actionForm",PageContext.PAGE_SCOPE)).getFormBean()).getContractNr()});
%>