• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

<body-content> "empty" still allowing content

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have been trying to figure out why the following situation is arising in <body-content>empty</body-content>. If I provide the entry in tld then specifying a content in the body of the tag should give an exception, but it's working smoothly in my case. Please see the following snippets:

Code from the tld:

<tag>
<name>advice</name>
<tag-class>com.example.AdvisorTagHandler</tag-class>
<body-content>empty</body-content>
<attribute>
<name>user</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

Code from the tag handler:

public void doTag() throws JspException, IOException{
getJspBody().invoke(null);
}

Code from the jsp using tag:

<mine:advice>
Content should not print...
</mine:advice>

When I debug the tag handler, getJspBody() does not return null. I am using Tomcat 6.0. Is it container specific property? Please help, this trivial issue has taken my lot of time.

 
Ranch Hand
Posts: 171
Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know your answer but you have asserted that attribute is required in tld,but are not providing one in the tag.
 
Vaib Gupta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the mistake. My container is ignoring all the body-content settings and taking 'scriptless' as the value. I know for tomcat the default is 'JSP' for tags, but I'm not sure why this behavior is occurring. Thanks for your reply. I will update with my findings.
 
Bindu Lakhanpal
Ranch Hand
Posts: 171
Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't answer about error in your container but as far as I know JSP is not the default for any of the tags
and in simple tags JSP are not allowed in body as the body content of JSPFragment does not support scriptlets.
check this faq link .
webpage
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting this problem as well and its driving me nuts. Either I completely misunderstand what a body-content of empty is meant to do, or there is a bug in my container implementation (Tomcat 6.0.18 on Linux).

I am expecting to see an error message when the second tag is encountered in the JSPX since the tag supplies a body, yet the TLD says "empty" for body-content. However my container is writing out the tag body regardless.


Here are the relevant files if someone would care to verify for me - maybe there is a really obvious mistake I've made below???


TestBodyContentEmptyBug.jspx



TestBodyContentEmptyBug.tld



TestBodyContentEmptyBug.java



Filename web.xml



Here is what my WAR file looks like:



J
 
Bindu Lakhanpal
Ranch Hand
Posts: 171
Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,same result in Tomcat 5.5.9 too.Output of your code is

About to call TestBodyContentEmptyBug...Done calling TestBodyContentEmptyBug...
--------------------------------------------------------------------------------
About to call TestBodyContentEmptyBug with a body...
Hello from the body of TestBodyContentEmptyBug... this body should cause an error... should it not?
Done calling TestBodyContentEmptyBug...
--------------------------------------------------------------------------------



But i remember testing similar program in case of simple tags on tomcat 6.0.18.And exception was raised there (i think) when tld declared the body content to be empty and i passed body in the invocation of tag.
Did you test for simple tags too?
 
Julian Corallo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for the replies so far - I've got a little further with this problem now.

It seems that it only happens with JSP Documents and not with JSP Pages.

So when I convert my TestBodyContentEmptyBug.jspx JSP Document to TestBodyContentEmptyBug.jsp JSP Page , the container successfully throws the expected error:

Filename TestBodyContentEmptyBug.jsp




The error message seen in the browser:




So - can anyone tell me why this is? Why would a JSP Document behave differently than a JSP Page with regard to body-content?

Cheers,

J
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see you've filed this as a bug in Tomcat: body-content of empty in TLD ignored for JSP Documents. That's probably the best move. I imagine this is an oversight in the JSP document translator, since the container can't enforce the "empty" content by XML schemas but instead has to do it programmatically at translation time, and I guess that test is missing in the translation engine. You could also try this on non-Tomcat containers (e.g. Caucho Resin) and see what behaviour that gives.
 
Julian Corallo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Yes I posted the bug this morning - so we'll see if an answer comes back on that.

I have the Sun GlassFish Enterprise v2.1 installed as well, but unfortunately this uses Tomcat code at the back end and so exhibits the same behavior!

I'll see what other containers I can get hold of then, and try them.

Cheers,

J
 
Julian Corallo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Further update.

I just tried this in Caucho Resin (http://www.caucho.com/) and both JSP Pages and Documents throw an error as expected.

So it looks like it is a problem in Tomcat.

Output from Caucho Resin below:



Filename TestBodyContentEmptyBug.jsp



Filename TestBodyContentEmptyBug.jspx



Cheers,

J
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic