<p>Embedded custom-tag in dynamic content (nested tag) not rendering.</p>

<p>I have a page that pulls dynamic content from a javabean and passes the list of objects to a custom tag for processing into html. Within each object is a bunch of html to be output that contains a second custom tag that I would like to also be rendered. The problem is that the tag invocation is rendered as plaintext.</p>

<p>An example might serve me better.</p>

<p>1 Pull information from a database and return it to the page via a javabean. Send this info to a custom tag for outputting.</p>

<pre><code>&lt;jsp:useBean id="ImportantNoticeBean" scope="page" class="com.mysite.beans.ImportantNoticeProcessBean"/&gt;  &lt;%-- Declare the bean --%&gt;
&lt;c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}"&gt; &lt;%-- Get the info --%&gt;
    &lt;mysite:notice importantNotice="${noticeBean}"/&gt; &lt;%-- give it to the tag for processing --%&gt;
&lt;/c:forEach&gt;
</code></pre>

<p>this tag should output a box div like so</p>

<pre><code>*SNIP* class for custom tag def and method setup etc
out.println("&lt;div class=\"importantNotice\"&gt;");
out.println("   " + importantNotice.getMessage());
out.println("   &lt;div class=\"importantnoticedates\"&gt;Posted: " + importantNotice.getDateFrom() + " End: " + importantNotice.getDateTo()&lt;/div&gt;");
out.println("   &lt;div class=\"noticeAuthor\"&gt;- " + importantNotice.getAuthor() + "&lt;/div&gt;");
out.println("&lt;/div&gt;");
*SNIP*
</code></pre>

<p>This renders fine and as expected</p>

<pre><code>&lt;div class="importantNotice"&gt;
    &lt;p&gt;This is a very important message. Everyone should pay attenton to it.&lt;/p&gt;
    &lt;div class="importantnoticedates"&gt;Posted: 2008-09-08 End: 2008-09-08&lt;/div&gt;
    &lt;div class="noticeAuthor"&gt;- The author&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>2 If, in the above example, for instance, I were to have a custom tag in the importantNotice.getMessage() String:</p>

<pre><code>*SNIP* "This is a very important message. Everyone should pay attenton to it. &lt;mysite:quote author="Some Guy"&gt;Quote this&lt;/mysite:quote&gt;" *SNIP*
</code></pre>

<p>The important notice renders fine but the quote tag will not be processed and simply inserted into the string and put as plain text/html tag.</p>

<pre><code>&lt;div class="importantNotice"&gt;
    &lt;p&gt;This is a very important message. Everyone should pay attenton to it. &lt;mysite:quote author="Some Guy"&gt;Quote this&lt;/mysite:quote&gt;&lt;/p&gt;
    &lt;div class="importantnoticedates"&gt;Posted: 2008-09-08 End: 2008-09-08&lt;/div&gt;
    &lt;div class="noticeAuthor"&gt;- The author&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Rather than </p>

<pre><code>&lt;div class="importantNotice"&gt;
    &lt;p&gt;This is a very important message. Everyone should pay attenton to it. &lt;div class="quote"&gt;Quote this &lt;span class="authorofquote"&gt;Some Guy&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;    // or wahtever I choose as the output
    &lt;div class="importantnoticedates"&gt;Posted: 2008-09-08 End: 2008-09-08&lt;/div&gt;
    &lt;div class="noticeAuthor"&gt;- The author&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I know this has to do with processors and pre-processors but I am not to sure about how to make this work.</p>

[{'answer_id': 49410, 'author': 'Georgy Bolyuba', 'author_id': 4052, 'author_profile': 'https://Stackoverflow.com/users/4052', 'pm_score': 2, 'selected': True, 'text': '<p>Just using </p>\n\n<pre><code>&lt;bodycontent&gt;JSP&lt;/bodycontent&gt;\n</code></pre>\n\n<p>is not enough. You should do soimething like </p>\n\n<pre><code>JspFragment body = getJspBody(); \nStringWriter stringWriter = new StringWriter(); \nStringBuffer buff = stringWriter.getBuffer(); \nbuff.append("&lt;h1&gt;"); \nbody.invoke(stringWriter); \nbuff.append("&lt;/h1&gt;"); \nout.println(stringWriter);\n</code></pre>\n\n<p>to get inner tags rendered (example is for SimpleTag doTag method). </p>\n\n<p>However, in the question\'s code I see that inner tag is comming from a string which is not rendered as a part of JSP, but just some random string. I do not think you can force JSP translator to parse it.</p>\n\n<p>You can use regexp in your case or try to redesign your code in a way to have a jsp like this:</p>\n\n<pre><code>&lt;jsp:useBean id="ImportantNoticeBean" scope="page class="com.mysite.beans.ImportantNoticeProcessBean"/&gt;\n&lt;c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}"&gt;\n    &lt;mysite:notice importantNotice="${noticeBean}"&gt;\n        &lt;mysite:quote author="Some Guy"&gt;Quote this&lt;/mysite:quote&gt;\n        &lt;mysite:messagebody author="Some Guy" /&gt;\n    &lt;/mysite:notice&gt;\n&lt;/c:forEach&gt;\n</code></pre>\n\n<p>I whould go with regexp.</p>\n'}, {'answer_id': 6538030, 'author': 'Samuel Marchant', 'author_id': 823341, 'author_profile': 'https://Stackoverflow.com/users/823341', 'pm_score': 0, 'selected': False, 'text': '<p>I would be inclined to change the "architecture of your tagging" in that the data you wish to achieve should not be by tag on the inside of the class as it is "markup" designed for a page(<em>though in obscurity</em> it is possible to get the evaluating program thread of the JSP Servlet engine).</p>\n\n<p>What you would probably find better and more within standard procedure would be using "cooperating tags" with  <code>BodyTagSupport</code> class extension and return <code>EVAL_BODY_BUFFERED</code> in doStartTag() method to repeat process the body <strong>and/or</strong> object sharing such as storing retrived data in the application hierarchy of the session or on the session for the user.</p>\n\n<p>See <a href="http://download.oracle.com/javaee/1.4/tutorial/doc/JSPAdvanced8.html" rel="nofollow">oracle j2ee custom tags tutorial</a> for more information.</p>\n'}]
['https://Stackoverflow.com/questions/49267', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3431280/']