wood burning stoves 2.0*
The moose likes JSP and the fly likes How to include page from custom tags 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 » Java » JSP
Bookmark "How to include page from custom tags" Watch "How to include page from custom tags" New topic

How to include page from custom tags

Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
(I'm repharsing my last problem)
How to include a jsp page/servlet mapping from a custom tag?
I have tried requestdispatcher.include(request, response), and the page's output does not display on the correct position on the HTML page.
I've tried pageContext.include("servletmapping"); and I got an exception thrown. Something about illegal to flush from within a Custom Tag.
Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
Seems like its impossible to include another page from nested tags of BodyTagSupport.
Here's a work around that I've found.
<ct:servletList default="/WEB-INF/props.list">
more html
// aServletTag class
public int doStartTag() throws JspException {
// Do dispatcher include
protected void flushParentBodyContent() throws JspException{
Tag parent=getParent();
if(parent != null && parent instanceof BodyTagSupport){
BodyTagSupport parentBodyTag=(BodyTagSupport)parent;
BodyContent parentBodyContent = parentBodyTag.getBodyContent();
try {
JspWriter writer = (JspWriter) pageContext.getAttribute("jspWriter");
} catch (IOException e) {
throw new JspException("IterationTag: " +e.getMessage());
I agree. Here's the link: http://aspose.com/file-tools
subject: How to include page from custom tags
Similar Threads
Determine if page to include exists or not!
accessing session object from Tag Handler class.?
Problem with custom tags
Q from Hanu's mock test
How to include servlets from tags?