1 Reply Latest reply on Mar 9, 2004 12:58 PM by darthjoe

    Including external XML into the web.xml descriptor

    darthjoe Newbie

      Hi all,
      I am pre-compiling my jsp's and outputting the servlet/url mappings to a file jsp_inc.xml

      I want to include that file in my web.xml file for my war project. If I cut an paste
      the jsp_inc.xml text into my web.xml it works fine. I was trying to use entities to
      include the file and not have to do the cut and paste. All the examples I have
      seen suggest the below entry should work, but it doesn't appear to. Any ideas?
      Are there any means to get debug output for the xml parser? By the way,
      I am using jboss 3.2.x

      Any help is much appreciated.

      Thanks,

      -Joe

      ################## WEB.XML FILE ############################
      <?xml version="1.0" encoding="ISO-8859-1"?>

      <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"
      [
      ENTITY jspinc SYSTEM "jsp_inc.xml"
      ]>

      <web-app>
      <display-name>Struts Example Application</display-name>

      <!-- Action Servlet Configuration -->

      <servlet-name>action</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>


      &jspinc;
      ################################
      .... Rest of xml file snipped


      ###########JSP_INC.XML TEXT BELOW ##################
      <!--
      Automatically created by Tomcat JspC.
      Place this fragement in the web.xml before all icon, display-name,
      description, distributable, and context-param elements.
      -->

      <servlet-name>em.jsp.genres.genre_display_jsp</servlet-name>
      <servlet-class>em.jsp.genres.genre_display_jsp</servlet-class>



      <servlet-name>em.jsp.index_jsp</servlet-name>
      <servlet-class>em.jsp.index_jsp</servlet-class>


      <servlet-mapping>
      <servlet-name>em.jsp.genres.genre_display_jsp</servlet-name>
      <url-pattern>/genres/genre_display.jsp</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
      <servlet-name>em.jsp.index_jsp</servlet-name>
      <url-pattern>/index.jsp</url-pattern>
      </servlet-mapping>
      <!--
      All session-config, mime-mapping, welcome-file-list, error-page, taglib,
      resource-ref, security-constraint, login-config, security-role,
      env-entry, and ejb-ref elements should follow this fragment.
      -->

        • 1. Re: Including external XML into the web.xml descriptor
          darthjoe Newbie

          Well I figured it out by using the file:// and using a full path

          <!DOCTYPE web-app
          PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
          "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"
          [
          ENTITY jspinc SYSTEM "file:///usr/local/emusic_dev/proto/emusic_app/emusic.war/WEB-INF/jsp_inc.xml"
          ]>

          The path appears to be evaluated relative to the bin/run.sh instead of relative to the emusic.war
          This becomes a problem if I don't know the full path to the file and want a relative uri. Anyone know any tricks to make this work? It seems like its a bug in the parser to evaluate the uri the way it is. Or maybe I am missing something simple??

          Thanks,

          -Joe