How to implement a "include" jsp tag?

Freewind picture Freewind · Feb 8, 2012 · Viewed 9.6k times · Source

I need to define a jsp tag which named "include". It should be used as:

<cms:include page="/aaa.jsp" />

It has an attribute page which points to another jsp, and it will include the content of that jsp and render it.

Is there any existing tag lib can do this? Or please give me some advises of implementing it, thanks!


UPDATE

From Ramesh PVK's answer, I know there is a standard <jsp:include> fit my need.

But per my project's requirements, I can use the name jsp:include, but cms:include. I've already defined some other tags which have prefix cms, and the include one should have the same prefix.

Is it possible to find the tld file for jsp:include? That I can copy the declarations to my tld file to reuse the tag with new prefix.

Answer

Ramesh PVK picture Ramesh PVK · Feb 8, 2012

Already there is a standard jsp tag for this.

This is to include page at runtime.
<jsp:include page="includedPage" />

and

This is to include page at compile time.
<%@ include file="banner.jsp" %>

Links: