Petr Mensik
Petr Mensik

Reputation: 27536

Taglib inheritance in jsp:include

Is it possible to inherit taglibs or imports from parent JSPs in their "descendants"?

Let me show you an example

header.jsp

<%@ page contentType="text/html" isELIgnored="false"
     import="org.something.utils.Constants"%>

//some code, Constants class is available here

index.jsp

<jsp:include page="template/header.jsp" />
//Constants is not available, I get a JasperException: Unable to compile class for JSP

also the taglibs inheritance doesn't seem to work. So is there a way how to make this work?

Upvotes: 0

Views: 1186

Answers (1)

engma
engma

Reputation: 1969

Taglibs and imports are not inherited, and everything in a tag as well cannot be inherited or passed through pages (except for JspContext and request attributes).

You have two options here:

  1. Make the import in every JSP you have.
  2. Make the common classes and libraries Global ones, this depends on the IDE and the server you are running.

Edit Defining JSP implicit includes:

  1. For Netbeans http://docs.oracle.com/cd/E19575-01/819-3669/bnajl/index.html
  2. A global tutorial http://sabahmyrsh.blogspot.com/2009/06/jsp-defining-implicit-includes.html

Upvotes: 1

Related Questions