aspose file tools*
The moose likes JSP and the fly likes nested tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "nested tags" Watch "nested tags" New topic
Author

nested tags

Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
Hello,

I am trying to understand how nested tags work for both classic and simple tags. This is my jsp snippet:


where Classic represents a Classic tag and Simple a Simple one.

The code snippet for the Classic tag is as follows:


The code snippet for the Simple tag is as follows:



The above snippet works fine when I try to execute.

Now when I do the reverse like :



an error is thrown which says:

/nested.jsp(14,1) jasper.error.bad.bodycontent.type
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
................................

Please let me know where I am going wrong?
[ May 13, 2008: Message edited by: Ken Sampson ]

Ken Sampson
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60992
    
  65

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

Originally posted by Ken Sampson:

<mine:Simple>
<mine:Classic />
</mine:Classic>

This syntax is not valid. You have self-closed the "classic" tag and supplied a closing tag. Do one or the other.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
Thanks a lot for pointing me the code formatting ... I guess this syntax is correct but i still receive the same error



I guess Classic tags cannot have Simple parents or there must be some other way to access. Please help..
[ May 14, 2008: Message edited by: Ken Sampson ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60992
    
  65

Your syntax is still wrong. Look at it carefully.
Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
Thanks a lot for pointing me out the error ... I guess this syntax is correct but i still receive the same error




I guess Classic tags cannot have Simple parents or there must be some other way to access. Please help..
John Pearson
Ranch Hand

Joined: Oct 19, 2007
Posts: 51
Classic tags certainly can have Simple tags as parents. Your code looks basically correct. Looking at your error message, though, my first suspicion would be that in your TLD, for Simple tag you have <body-content>empty</body-content> instead of "scriptless".
Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
Thank you John for your reply ..for your reference please find the TLD file below:



Please let me know if I am doing anything wrong
[ May 14, 2008: Message edited by: Ken Sampson ]
John Pearson
Ranch Hand

Joined: Oct 19, 2007
Posts: 51
Well, I'm baffled. Your TLD looks good, your code looks good. I decided to try it myself, cutting and pasting your code snippets. I had to add declarations for nestedLevel and write, but I know you've got those in there or it wouldn't have compiled. When I ran it, it worked just fine! It produced the output: Tag at nestedLevel 0 1.

I guess what I would try at this point is to comment out everything in doStartTag() except the return, and see if that gets rid of the error. If it does, start adding code back in a line or two at a time.

I can't help but think that a bad.bodycontent.type error is a syntax problem in the TLD or JSP page, but I sure don't see any problems in what you've posted.
Prem Nazeer Mohamed Ali
Greenhorn

Joined: Jul 15, 2009
Posts: 1
In the tld file change the below

<body-content>scripless</body-content>

to

<body-content>scriptless</body-content>

it should work.
Musa Ali
Greenhorn

Joined: Jun 19, 2013
Posts: 2
I haven't tested this, and obviously there is a fault in your TLD (the "scripless" instead of "scriptless") but if you look at the documentation, TagSupport and BodyTagSupport store parent as a "tag" where as SimpleTags store it as "JspTag". So if you know the class family tree, you'd know that this means that Simple tags can have any tag as it's parent (JspTag is the base class) While Tags would only allow other Tags as a SimpleTag can not be stored in a Tag variable.

At least this is what it should do theoretically
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: nested tags