Making scriptlets invalid in JSPs

2019-02-27 05:41发布

问题:

I am trying to make scriptlets invalid by writing the below code in my Deployment descriptor but still the scriptlets are getting executed.

<jsp-config>
        <jsp-property-group>
            <url-pattern>*.jsp</url-pattern>
            <scripting-invalid>false</scripting-invalid>

            <el-ignored>true</el-ignored>
        </jsp-property-group>
    </jsp-config>

回答1:

You need to configure it the other way round.

<scripting-invalid>true</scripting-invalid>
<el-ignored>false</el-ignored>

When the <scripting-invalid> is set to true, then the container will throw an exception when scriptlets (those <% %>, <%= %> and <%! %> things) are still used.

You definitely don't want to set <el-ignored> to true, otherwise you won't be able to use expression language (those ${} things), which is the recommended way of accessing the model and executing functions in JSPs. If you disable it as well, then all your JSPs would be useless and can be plain static HTML files as good.



回答2:

I think the jsp's are already converted to Java servlets. Try regenerating the jsp to servlets.