Programming Tutorials

Disabling Scriptlets in JSP using web.xml

By: Emiley J in JSP Tutorials on 2007-09-23  

The EL is intended to replace the use of Java scriptlets in developing JSPbased web applications. To this end, it's possible to disable the evaluation of scriptlets through configuration parameters. This allows a developer to ensure that no one inadvertently uses scriptlets instead of the EL. This can allow best practices to be more easily enforced.

You can disable scriptlets within a page using the web.xml deployment descriptor by choosing to disable evaluation for a single page, a set of pages, or for the entire application. The tags that you need to add to the deployment descriptor are within the <jsp-config> element. The following example disables scriptlets for all JSP pages within an application:

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

The <url-pattern> element can represent a single page, for example:

<jsp-config>
<jsp-property-group>
<url-pattern>/test.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
</jsp-config>

It can also represent a set of pages, for example:

<jsp-config>
<jsp-property-group>
<url-pattern>/noscriptlets/</url-pattern>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
</jsp-config>






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in JSP )

Latest Articles (in JSP)