You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Steve O'Hara <so...@pivotal-solutions.co.uk> on 2004/10/22 11:09:44 UTC

Template Cacheing

This is my first Velocity servlet app and I'm running into a couple of
issues.

I'm using Tomcat 4.x and my servlet extends VelocityServlet.  This is
working fine except that changes to my templates made whilst Tomcat is
running are not made apparent in Velocity i.e. Velocity is cacheing the
template and doesn't re-read it until I close Tomcat and re-start it.  Why
is this and what can I do to defeat it?

Thanks,

Steve






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


RE: Template Cacheing

Posted by Steve O'Hara <so...@pivotal-solutions.co.uk>.
Hi Shinobu,

Yeh, it's a mystery..........
To check that it definitely wasn't the browser cache, I set an expires
header and no-cache control.
Also, I switched from IE to Mozilla whilst Tomcat was running and it still
showed the cached page.
It does show any changed context data, which would also indicate that it
isn't a browser issue.

I suppose I'm getting to the poitn where I'll need to download the Velocity
source and debug it.......?

Steve


-----Original Message-----
From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com]
Sent: 23 October 2004 17:38
To: Velocity Users List
Subject: Re: Template Cacheing


Hi Steve,

> Thanks for your notes, but I still can't turn the cacheing off.
>
> This is my code............

## snip

> What am I doing wrong ?
Hmm.  AFAICS, nothing.  Actually your code worked in my environment.
(I use Tomcat 5.5, but that shouldn't matter.)  Even more,
FileResourceLoader doesn't cache by default.  Could it be that your
browser is caching, and not Velocity?

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>

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




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


Re: Template Cacheing

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Steve,

> Thanks for your notes, but I still can't turn the cacheing off.
> 
> This is my code............

## snip

> What am I doing wrong ?
Hmm.  AFAICS, nothing.  Actually your code worked in my environment. 
(I use Tomcat 5.5, but that shouldn't matter.)  Even more,
FileResourceLoader doesn't cache by default.  Could it be that your
browser is caching, and not Velocity?

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

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


RE: Template Cacheing

Posted by Steve O'Hara <so...@pivotal-solutions.co.uk>.
Hi Shinobu,

Thanks for your notes, but I still can't turn the cacheing off.

This is my code............



protected Properties loadConfiguration(ServletConfig objConfig) throws
IOException, FileNotFoundException
    {
        Properties objProps = new Properties();
        String sPath = objConfig.getServletContext().getRealPath("/");
        if (sPath == null) {
            System.out.println(ERR_HEADER + "Unable to get the current
webapp root");
            sPath = "/";
        }
        objProps.setProperty("file.resource.loader.path", sPath +
"/templates");
        objProps.setProperty("file.resource.loader.cache", "false");

objProps.setProperty("file.resource.loader.modificationCheckInterval", "5");
        objProps.setProperty("runtime.log", sPath + "/log/corrman.log" );
        return objProps;
    }

public Template handleRequest(HttpServletRequest objRequest,
HttpServletResponse objResponse, Context objContext) {

        objContext.put("Title", "Hello Steve");

        Template objOutput = null;
        try {
            objOutput = getTemplate("test.vm");
        }
        catch (ParseErrorException objParseErr) {
            System.out.println(ERR_HEADER + "Parse error for template " +
objParseErr.getMessage());
        }
        catch (ResourceNotFoundException objResErr) {
            System.out.println(ERR_HEADER + "Template not found " +
objResErr.getMessage());
        }
        catch (Exception e) {
            System.out.println(ERR_HEADER + e.getMessage());
        }
        return objOutput;
    }
}

What am I doing wrong ?

Thanks,

Steve



-----Original Message-----
From: Shinobu Kawai [mailto:shinobu.kawai@gmail.com]
Sent: 22 October 2004 14:42
To: Velocity Users List
Subject: Re: Template Cacheing


Hi Steve,

> I'm using Tomcat 4.x and my servlet extends VelocityServlet.  This is
> working fine except that changes to my templates made whilst Tomcat is
> running are not made apparent in Velocity i.e. Velocity is cacheing the
> template and doesn't re-read it until I close Tomcat and re-start it.  Why
> is this and what can I do to defeat it?
First, I suggest using VelocityViewServlet.
    http://jakarta.apache.org/velocity/tools/view/index.html
Next, snoop around these documents and posts about resource loaders and
cache.

http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resour
ce%20Loaders
    http://article.gmane.org/gmane.comp.jakarta.velocity.user/7783

If you still can't get it to work, ask again with some detail of how
you configured the resource loader.

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>

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




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


Re: Template Cacheing

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Steve,

> I'm using Tomcat 4.x and my servlet extends VelocityServlet.  This is
> working fine except that changes to my templates made whilst Tomcat is
> running are not made apparent in Velocity i.e. Velocity is cacheing the
> template and doesn't re-read it until I close Tomcat and re-start it.  Why
> is this and what can I do to defeat it?
First, I suggest using VelocityViewServlet.
    http://jakarta.apache.org/velocity/tools/view/index.html
Next, snoop around these documents and posts about resource loaders and cache.
    http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resource%20Loaders
    http://article.gmane.org/gmane.comp.jakarta.velocity.user/7783

If you still can't get it to work, ask again with some detail of how
you configured the resource loader.

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai <sh...@gmail.com>

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