Thursday, December 30, 2010

Disabling the Scriplets in JSP

You might be knowing that writing the scriplet tags in JSP is a Crime according to MVC(Model View Controller ) Design Pattern

you can restrict that configuring some tags in JSP as follows.



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>


Thanks..

No comments:

Post a Comment