Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scripting-Invalid(Usage)

 
Sudhakar Guntaka
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to disable all the scripting elements in a JSP page by using "<scripting-invalid>" tag in DD. Even though I unable to disable scripting elements.
They(scripting elements) are being processed by JSP and I am able to see the result of Scripting elements. But it should not happen. We must see scripting code without prcessing. Right!!!
Please help me to sortout this issue.......

cheers,
Sudhakar.
 
Sami Sayeed
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
make sure you are using tomcat 5.1

<jsp-config>

<jsp-property-group>
<description>
Special property group for JSP Configuration JSP example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>


</jsp-property-group>
</jsp-config>

try this out..
cheers
Sami
 
Sudhakar Guntaka
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sami,
I am using Tomcat 5.0.28. I did like this.

(first.jsp)

<%out.print("This is text in JSP");%>
<%out.print("This is another text in JSP");%>
Value: <%=9%>


(web.xml)

<web-app>
<servlet>
<servlet-name>hello</servlet-name>
<jsp-file>/first.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>

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

</web-app>

and I invoked the JSP page. I am getting

This is text in JSP This is another text in JSP 9

but I should not get like this. Right !!! Where I am going wrong??

cheers,
Sudhakar.
 
Sami Sayeed
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sudhakar,

try this out.

1. make some changes in your jsp, like add a space or whatever..
2. now try giving a request.
I tried it at my end and seems to work fine.

cheers
Sami
 
Abhishek Mahanty
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sudhakar:
Hi,
... I am able to see the result of Scripting elements. But it should not happen. We must see scripting code without prcessing. Right!!!


Hi, if you disable scripting in web.xml i.e.

<scripting-invalid>true</scripting-invalid>

Then you should get a Translation Error if the jsp engine encounters any scripting element in your JSP page. So you don't get to see any "scripting code without processing". (Refer JSP 2.0 specs Table JSP.3-3)

BUT the EL ignored setting behaves differently i.e. if we have

<el-ignored>true</el-ignored>

Then we get to see the EL expressions in their unevaluated form (NO Translation Error in this case).

Abhi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic