[JSP/Newbie]: howto write my own <jsp:include> tag?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ingo_Ciechowski
Posted On:   Sunday, May 26, 2002 01:05 AM

Hi folks, I'm trying to write a replacement tag for (which shall later decide upon its context what to include..), i.e. I want to *include* another JSP from within a tag. Unfortunately right now my best bet does not allow to control the position of the included JSPs output in my output stream - it prints directly :-(( // // index.jsp is my startpage: <%@ taglib uri="/cistags" prefix="cis" %> index.jsp START: <cis:include file="/theincludefile.jsp" /> index.jsp ENDE // // theincludefile.jsp is the included file: -->INCLUDEFILE<   More>>

Hi folks,


I'm trying to write a replacement tag for (which shall later decide upon its context what to include..), i.e. I want to *include* another JSP from within a tag.


Unfortunately right now my best bet does not allow to control the position of the included JSPs output in my output stream - it prints directly :-((



//

// index.jsp is my startpage:

			
<%@ taglib uri="/cistags" prefix="cis" %>
index.jsp START:
<cis:include file="/theincludefile.jsp" />
index.jsp ENDE


//

// theincludefile.jsp is the included file:

			
-->INCLUDEFILE<--


//

// include.java is my current idea to approach this:

			
public class include extends TagSupport {
private String jspName;

public void setFile(String name) {
this.jspName = name;
}

public int doEndTag() {

HttpServletRequest request =
(HttpServletRequest) pageContext.getRequest() ;
HttpServletResponse response =
(HttpServletResponse) pageContext.getResponse() ;

try {
request.getRequestDispatcher(
response.encodeURL(jspName)).include(request,response) ;
}
catch (Exception e) { }

return EVAL_PAGE;
}
}



the result expected is:

			
index.jsp START:
-->INCLUDEFILE<--
index.jsp ENDE


but instead I receive:

			
-->INCLUDEFILE<--
index.jsp START:
index.jsp ENDE




So how can I get hold of the ouput generated by the JSP I'm calling through RequestDispatcher.include so that I can rewrite it into my own output stream here?


Is someone out there able to point me into the right direction?



--

Ingo

ciechowski@cis-computer.com

   <<Less

Re: [JSP/Newbie]: howto write my own &lt;jsp:include&gt; tag?

Posted By:   Anonymous  
Posted On:   Tuesday, May 28, 2002 02:38 PM

Take a look at PageContext.include.
About | Sitemap | Contact