This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes question on rtexprvalue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "question on rtexprvalue" Watch "question on rtexprvalue" New topic
Author

question on rtexprvalue

Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

Hi guys,

I have a question about rtexprvalue in a custom tag.

For testing, I made this incredible calculator tag, which takes an i and a j and adds them together.
I don't want j to accept EL so I did



and indeed, if I say


I get an exception about my tld that says I can't use expressions etc.
But when I do it like this:


It doesn't complain and takes the EL ?!

any idea why it does this?

thanks!


I know where my towel is. (SCJP 5, OCPJWCD)
[Free Quiz Tips for a fun night with friends or family] Flash games
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Hi Mark,

What server are you using?

If I try your example on tomcat 5.5 I get an exception:
org.apache.jasper.JasperException: /jsp/index.jsp(121,27) Expression language not allowed in a template text body.


Regards,
Frits
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

hi Fritz, thanks for all your answers!

hmm I use apache-tomcat-6.0.29 .. I seem to be getting a lot of strange stuff with my installation

I got the error, changed only the jsp to the jsp:attribute version, and then it worked. Can't see
what I've done wrong...
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Can you post all of your code and your TLD entry?

Maybe we are overlooking something.

Regards,
Frits
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

Hi Fritz,

I think I found the cause. Although I don't understand it..

I had the dynamic-attributes on in my tld and in my class.
If it is there, I can use EL in jsp:attribute ,if it's not, I get an exception.





and the tld:



the java file:

Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

It looks like you have found a small error!

According to jsp2.0 specs
Dynamic attributes must be considered to accept request-time expression values.

but that does not mean that all the (tld) declared attributes are suppose to accept rtevalues as well....

Regards,
Frits
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

woehoe! did I win anything ?

they can ask me this tomorrow on the exam!
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

did I win anything ?

Respect

they can ask me this tomorrow on the exam!

Good luck tomorrow! (n.b. have a look at my notes, just for the cramming part, ScwcdLinks, section rancher notes)

Regards,
Frits
Mark Uppeteer
Ranch Hand

Joined: Mar 02, 2004
Posts: 159

thanks!

I did look at your notes, they are really great! actually the best I could find


just a small error in the notes:

1)There is no <jsp:directive.taglib p7.52
its also in the hfsj book but you got to be careful not to read over it.
2)there is no HAND http method ;) (first page)

Yesterday I took the final hf exam and scored (after errata) 72% ,and I even made some stupid mistakes.
So I'm pretty confident I should pull this one off tomorrow

anyway, you'll hear from me tomorrow around noon!>
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

just a small error in the notes:

1)There is no <jsp:directive.taglib p7.52
its also in the hfsj book but you got to be careful not to read over it.
2)there is no HAND http method ;) (first page)

Well spotted!

Thanks, corrected it immediatly and published a new version (how did I ever come up with the method HAND )

Regards,
Frits
Ankur Gargg
Ranch Hand

Joined: Sep 11, 2011
Posts: 55

Hi

Can you please explain the reason once again for the two different scenarios?

Please help needed.





Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Can you please explain the reason once again for the two different scenarios?

Do you mean why Mark did not get an exception in this case?
That was because he set the dynamic attributes in the TLD file to true, meaning that that tag could take more attributes apart from "i" and "j" (although Marks implementation is not showing a good example of how to implement dynamic attributes, have a look here)

Dynamic attributes will according to the specs accept rtexprvalues, but the attribute "j" has been defined as <rtexprvalue>false</rtexprvalue> and is not one of the dynamic attributes, so an Exception should be thrown by the container. We saw that the exception was thrown in the other case: <calc:add i="5" j="${3+5}" ></calc:add>.

That makes it a small mistake in of Tomcat: it should have thrown an exception in both cases...

Did this answer your question?

Regards,
Frits
Ankur Gargg
Ranch Hand

Joined: Sep 11, 2011
Posts: 55

Hi Fritz

Can you give me the exact link for your notes?
I am not able to find them anywhere.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

ScwcdLinks and then look for the Rancher Notes section.

Regards,
Frits
 
Don't get me started about those stupid light bulbs.
 
subject: question on rtexprvalue
 
Similar Threads
jsp.error.badaction
jsp actions + expr values
Doubt in jsp:attribute
problem on c:set
doubt in value for rtexprvalue element in tld