Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a "include" jsp tag?

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.

like image 818
Freewind Avatar asked Nov 23 '25 23:11

Freewind


1 Answers

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:

  • See this tutorial
  • Reference
  • Different between jsp:include and @include
like image 153
Ramesh PVK Avatar answered Nov 25 '25 17:11

Ramesh PVK