Was reading thru the list/google - since we needed a non-singleton
version of VVS. So - the following is using Velocity tools from
subversion as of today 6. may.

While reading I found some articles where it suggested to use
mime-mappings instead of overriding the VelocityViewServlet for each
mime-type and overriding the setContentType method for each. Makes
sense to me - three servlets -> one.

Have the following sections in web.xml:

   <servlet>
      <servlet-name>VelocityView</servlet-name>
      <display-name>VelocityView</display-name>
     <servlet-class>no.empolis.servlet.VelocityView</servlet-class>

      <load-on-startup>2</load-on-startup>

   </servlet>

   <servlet-mapping>
      <servlet-name>VelocityView</servlet-name>
      <url-pattern>*.vm</url-pattern>
   </servlet-mapping>
   <servlet-mapping>
      <servlet-name>VelocityView</servlet-name>
      <url-pattern>*.txt</url-pattern>
   </servlet-mapping>
   <servlet-mapping>
      <servlet-name>VelocityView</servlet-name>
      <url-pattern>*.css</url-pattern>
   </servlet-mapping>

  <mime-mapping>
    <extension>.txt</extension>
    <mime-type>text/plain</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>.css</extension>
    <mime-type>text/css</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>.vm</extension>
    <mime-type>text/html</mime-type>
  </mime-mapping>


Note - the custom servlet VelocityView simply overrides the doRequest
method - looks at the IP address of the request and sets a value in
the http session object then calls super.doRequest() - nothing about
Content Type. One particular internal machine needs a different view
than all the others :)

Now - without the mime-mapping section - any .vm files are returned as
text/plain (they are normally called via the struts servlet
framework). With the mime-mapping section - the .vm files are returned
as text/html - and therefore render in the browser.

However - the css files (which are called directly - not thru the
struts framework) also return as text/html - not text/css. The content
is correctly parsed by velocity - it's just the content type that is
wrong.

What have I misunderstood here - is this not the correct way to use
the mime-mappings settings? Should this work with VVS?

-- 
Chris Searle


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to