wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Scripting Invalid Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Scripting Invalid" Watch "Scripting Invalid" New topic
Author

Scripting Invalid

Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
what is the output of the following code


SCJP 5 |SCWCD 5| Started thinking about Web Services ?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

What do you think the output could be ?


[My Blog]
All roads lead to JavaRanch
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Christophe Verre:
What do you think the output could be ?


Hi Verre,

i tried This, surprise! i am getting output.

i able to use scripting(<%%> in main/page1.jsp.

please anyone can explain me
[ August 12, 2008: Message edited by: seetharaman venkatasamy ]
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
As per my view output should be
<% int i=12; %>
<%= i %>

[ August 12, 2008: Message edited by: Chintu sirivennela ]
deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
I go with chintu's Answer.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi chintu and deepa,

i tried but i did not get your answare...i can not invalid the scripting... where i am wrong?...any idea please
deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
while accessing the page ,

Exception was thrown.

org.apache.jasper.JasperException: /test.jsp(1,4) Scripting elements ( <%!, <jsp eclaration, <%=, <jsp:expression, <%, <jsp:scriptlet ) are disallowed here.


:-(
deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
hi seetharaman,

/main/page1.jsp may reside somewhere else.

It should be <context-root>/main/page1.jsp


If you are enabling the scripting-invalid , it will give runtime exception.
[ August 12, 2008: Message edited by: deepa raj ]
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Deepa raj, Why that got exception..So our expectation is wrong.
So what would be the reason can some one answer this.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Chintu sirivennela:
..So our expectation is wrong.


No. you are correct according to the <scripting-invalid>... but here i am struggling to implement it in web.xml...the jsp is not understanding here...thats my problem,,,

but answare should be your expectation
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by deepa raj:
hi seetharaman,

/main/page1.jsp may reside somewhere else.

It should be <context-root>/WEB-INF/main.page1.jsp


If you are enabling the scripting-invalid , it will give runtime exception.


is it necessary to my jsp should inside WEB-INF?
deepa raj
Ranch Hand

Joined: Jul 25, 2008
Posts: 124
Mistakenly i have put WEB-INF.

it should be <context-root>/main/page1.jsp
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

According to JSP.3.3.3 Disabling Scripting Elements, setting scripting-invalid to true results in a Translation Error when scripting is encountered.
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Thank so much Christophe Verre,

I thought if we disable scripting , the container is treated scripting as normal text. My understanding was wrong.

Once again thanks for your help here in this forum(I got lot of clarifications and help from you).
Sandeep Bhandari
Ranch Hand

Joined: Apr 16, 2004
Posts: 201
well guess what will be the output if el-igonred is true in Deployment Descriptor and the container/compiler encounters some Expression Language (sort of $())


SCJP 96% | SCWCD 90%| SCJP mock exams | My SCJP blog
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
if you use the tag <el-ignored>, then the output will be as it is in the output. The container will not compalin about it.


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
SO finally
1. If <el-ignored> true, if JSP contains any EL code it ignores to execute as EL, container treat that as normal text and displays normal text
2. <scripting-invalid> true, then if container encounters any scripting code it will throw Translation Error

Correct me If I am wrong.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

That's correct.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

yesterday i tried in GlassFish server..thats why i confused. you will get different output in that server
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I tried using Glassfish :
org.apache.jasper.JasperException: /test.jsp(2,2) PWC6203: Scripting elements ( <%!, <jsp:declaration, <%=, <jsp:expression, <%, <jsp:scriptlet ) are disallowed here.

Here is my web.xml :


Check yours. Maybe you'll need to clear some cache ?? (I didn't).
[ August 12, 2008: Message edited by: Christophe Verre ]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Yes . Verre you are correct. today i got what you said. but yesterday in my JSP,scripting-invalid not working only!!!

i do not know the problem

Thanks Verre.
Sandeep Bhandari
Ranch Hand

Joined: Apr 16, 2004
Posts: 201
An easier way to remember the outcome in both cases is as:

el-ignored -- ignored means that what you considered code will now be template text
scripting-invalid -- the code which you thought to be a scriptlet will cause an exception because it is invalid



Thus focus on the two words:
ignored
invalid
Amruth Puppala
Ranch Hand

Joined: Jul 14, 2008
Posts: 295
Great understanding Sandeep Bhandari
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scripting Invalid