wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes <jsp:expression> format not working in tag attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "<jsp:expression> format not working in tag attribute" Watch "<jsp:expression> format not working in tag attribute" New topic
Author

<jsp:expression> format not working in tag attribute

Dinkar Chaturvedi
Ranch Hand

Joined: Mar 27, 2007
Posts: 36
Howdy ranchers,

Today I came across an interesting behaviour while trying to pass an object to tag attribute via scripting. Basically I wanted to test if both formats of scripting expression are identical in behaviour. From the output, I feel like they aren't. Not sure if this is correct behaviour or not.

So I passed two attributes (using dynamic attributes) one with the usual syntax: <%=application.getAttribute("obj")%> and the other with <jsp:expression>application.getAttribute("obj")</jsp:expression>. The tag file simply prints the attributes with the details like name, value, type etc.

JSP that calls my tag file. It simply passes two attributes with same values. The only difference is the syntax elements used to pass the objects.


Tag file code is simple. It just iterates thru all the dynamic attributes and prints the name and value to the output stream along with their class type of the attribute value.


Output:
Please note that the mymodel.Dog's toString() method has been overriden to print the default implementation value (the object class@hashcode) + the name of the property in the object which is dalmatian by default as in this case.

newScrVar='application.getAttribute("appDog")'----java.lang.String
scriptingVar='mymodel.Dog@6e72d873: breed=dalmatian'----mymodel.Dog


Is this the expected behaviour? If not, is this a bug? Or something wrong with my understanding or doing things?

I am using Tomcat 7.0.46.

Regards
Dinkar
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 219

Can you please check if you are getting value in

And if yes then can you please put <%= %> instead of using <jsp:expression> tag.

Tell us what is happening after that.

I don't think this should be expected behaviour because value of <jsp:expression> tag is not been evaluated by jsp and it is printed as it is in the output.


OCPJP
Dinkar Chaturvedi
Ranch Hand

Joined: Mar 27, 2007
Posts: 36
Hi Ishan,

Yes, that was the first thing I tried. Everything works fine outside attributes. I am able to see the expected output for both <%= %> and <jsp:expression> when used outside attributes.

Regards
Dinkar
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 219

Is there a need of the use of single quotes ('') here

??
I am not sure if it effects the code or not. But have you tried it with double quotes?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <jsp:expression> format not working in tag attribute
 
Similar Threads
A doubt about tag without body content
Can you read this?
Question about jsp:attribute body
XML syntax for jsp
info attribute of page directive