velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <archana.b...@wipro.com>
Subject Processing Templates with #parse
Date Thu, 07 Jul 2005 03:22:49 GMT

Hi,
I'm new to velocity. I'm trying to get the integration of velocity and
struts going.

VelocityViewServlet is being used to handle all the calls to *.vm files.

Find below the snippet from web.xml:

<servlet>
   <servlet-name>VelocityViewServlet</servlet-name>		  

<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServle
t</servlet-class>

      <init-param>
        <param-name>org.apache.velocity.toolbox</param-name>
	<param-value>/WEB-INF/toolbox.xml</param-value>
       </init-param>
   
	<init-param>
	   <param-name>org.apache.velocity.properties</param-name>
           <param-value>/WEB-INF/velocity.properties</param-value>
    	</init-param>
	   
</servlet>

Also a piece of struts-config:
<action path="/jsp/home" type="presentation.availability.HomeAction">
  <forward name="HomePage"
path="/templates/availability/homepagetemplate.vm" />
</action>

The properties set in velocity.properties are:

file.resource.loader.path = templates
runtime.log = velocity.log

While processing homepagetemplate, ResourceNotFoundException is thrown
because it has

#parse("availability/propertytemplate.vm")

It tries to find the template directly under the web app working
directory and not from the root specified from the properties file
("templates").
I guess processing the "homepagetemplate.vm" was fine because
strutsconfig has the complete path.

Could some one point me out the point at which i'm doing it incorrectly?

I also found this piece of code in VelocityViewServlet:

protected Template handleRequest(HttpServletRequest request,
                                     HttpServletResponse response,
                                     Context ctx)
        throws Exception
    {
        // If we get here from RequestDispatcher.include(),
getServletPath()
        // will return the original (wrong) URI requested.  The
following special
        // attribute holds the correct path.  See section 8.3 of the
Servlet
        // 2.3 specification.
        String path =
(String)request.getAttribute("javax.servlet.include.servlet_path");
        if (path == null)
        {
            path = request.getServletPath();
        }
        return getTemplate(path);
    }

This always returns the template name from the servletPath(). So when
would the VelocityContext properties (for root of template etc.) be
used??

Another query in this context is - where is VelocityContext information
stored after the init() method of the VelocityViewServlet. (I did find
the TooblBoxContext in the ChainedContext, but not VelocityContext
though).

Thank you,
Archana.




Confidentiality Notice

The information contained in this electronic message and any attachments to this message are
intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information.
If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com
immediately
and destroy all copies of this message and any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message