AbdulAziz
AbdulAziz

Reputation: 6298

Multiple taglib files in jsp configuration in web.xml?

I am integrating security to my MVC application using spring security. My web.xml snippet is as bellow:

...
<jsp-config>
    <taglib>
      <taglib-uri>/spring</taglib-uri>
      <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
    </taglib>
  </jsp-config>

</web-app>

As I am reading / searching in the spring security reference I found this page at the end of the page, related to taglib. Now in my existing MVC application, I already have .tld file as shown in above snippet. Should I add another .tld file for the security e.g security.tld and define it in web.xml? How should I use? Like this:

<taglib-location>
             /WEB-INF/tld/spring-form.tld
             /WEB-INF/tld/security.tld
</taglib-location>

Or like this:

        <taglib>
          <taglib-uri>/spring</taglib-uri>
          <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
        </taglib>
        <taglib>
          <taglib-uri>/security</taglib-uri>
          <taglib-location>/WEB-INF/tld/security.tld</taglib-location>
        </taglib>

Please help. Thank you

*EDIT: * I am using spring 2.5.6 and security 2.0.4

Upvotes: 0

Views: 3928

Answers (1)

Emmanuel Ballerini
Emmanuel Ballerini

Reputation: 684

One option is to move the declarations into a common JSP (if you use JSPs), like this:

<%@ taglib uri="/WEB-INF/tld/spring-form.tld" prefix="spring" %>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="security" %>

Then you can reference that JSP anywhere you want to use one of those tags, as follow (works well in a template if you use Tiles or Sitemesh for instance)

<%@ include file="/jsp/common/taglibs.jsp" %>

Upvotes: 2

Related Questions