velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <>
Subject Re: Webapp resource loader problem
Date Thu, 03 May 2007 01:36:44 GMT
On 5/2/07, Dan Nicolici <> wrote:
> Hi, all!
> I'm using VelocityViewServlet in my webapp and I came across a weird
> problem. Every time I open a new browser window and call my webapp URL,
> the variables from my .vm are shown instead of the desired content (like
> $varname). This only happens the on first access on a new browser
> window. After I hit refresh in the browser everything is ok (I get the
> desired content). Then, if I open a new instance of the browser, the
> same thing happens all over again (the webserver is not shutdown between
> the two actions).

That's odd.  What do your servlet logs say on the first hit? (and
perhaps on the second also)?

> I am using Tomcat 5.5. The servlet is declared in the web.xml like this:
>     <servlet>
>         <servlet-name>MyServlet</servlet-name>
>         <servlet-class>
>            package.UsersServlet
>         </servlet-class>

i presume this is a subclass of VelocityViewServlet?

>         <init-param>
>             <param-name></param-name>
>             <param-value>/WEB-INF/</param-value>
>         </init-param>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>MyServlet</servlet-name>
>         <url-pattern>/index.html</url-pattern>
>     </servlet-mapping>
> looks like this:
> resource.loader = webapp
> webapp.resource.loader.class =
> webapp.resource.loader.path = /templates
> # Set cache to true for production
> webapp.resource.loader.cache = false
> webapp.resource.loader.modificationCheckInterval = 60
> velocimacro.library = myMacro.vm
> Can you please help me in getting the right content from the first page
> access? What am I doing wrong (cause I must be doing something wrong)?

it's hard to tell with the information given.  you can always try
comparing your application to the "simple" example app that comes with
VelocityTools and see where things are different.  i can tell you that
this is not llikely to be a problem with the resource loader.   it
seems like either your context is not populated on first request, or
else the template is being processed (if at all) by something besides
your VelocityViewServlet subclass.

also, what version of VelocityTools are you using? (probably not
relevant, but i'm curious.)

> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message