users@glassfish.java.net

Re: Declaring Custom File Extensions

From: <Jan.Luehe_at_Sun.COM>
Date: Thu, 08 May 2008 10:28:22 -0700

glassfish_at_javadesktop.org wrote:

>>I do not fully understand your question. Especially
>>not which files you want to parse?
>>
>>If you want extensions other than ".jsp" to be
>>handled by the JspServlet you simply have to change
>>the servlet-mapping element of the default-web.xml
>>for the JspServlet. This is the Servlet that takes
>>care of JSPs, triggers their transformation to
>>Servlets and so on. The default-web.xml can be found
>>in the config-directory of your domain. E.g.
>>GF_HOME/domains/domain1/config/default-web.xml
>>
>>
>
>Okay, I find this element:
><servlet-mapping>
><servlet-name>jsp</servlet-name>
><url-pattern>*.jspx</url-pattern>
></servlet-mapping>
>
>1) I thought the extension was just .jsp (not .jspx)?
>
>

See the JSP spec:

  JSP documents, that is, JSP pages that are delivered as XML
  documents, use the extension .jspx by default.

>2) Would this add my own extension .xyz?
><servlet-mapping>
><servlet-name>jsp</servlet-name>
><url-pattern>*.jspx</url-pattern>
><servlet-name>jsp</servlet-name>
><url-pattern>*.xyz</url-pattern>
></servlet-mapping>
>
>

A portable way of doing this would be to declare a JSP property group in
your web.xml,
as follows:

  <jsp-property-group>
    <url-pattern>*.xyz</url-pattern>
  </jsp-property-group>

This would cause any resources with .xyz suffix in your webapp to be
considered
as JSP pages. See the JSP spec for more details about
<jsp-property-group> and
its subelements.


Jan