You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Melehin Anton <me...@mail.ru> on 2002/03/10 17:13:29 UTC

a problem with template loading

Hello All.

  I'm using Velocity 1.2 for 1 week.

  Yesterday, I've finished a simple servlet that uses VelocityServlet as base
  class. This servlet use 10 templates for its work. It
  load them by calling method getTemplate (for example getTemplate('html/show.vm.html') )
  of  VelocityServlet.

  When I deployed it to the test application, almost everything were fine for me.

  After that, I decided to deploy this servlet to my
  web-applications. I put servlet settings to the web.xml in 3
  other web-applications.

  There are separate templates for every
  applications. So in every .war were separate copy of my templates
  (html/). I made 3 .war and deployed them to the Tomcat 3.2.2. Everything
  were Ok, until I decided to change template in one of applications.
  I can see those changes in other applications!

  After that I read docs and understood that Velocity can use two
  'schemas' of using templates:
  1.one engine for JVM
  2.separate engine for every application.

  Every servlet instance use same name ('html/show.vm.html') for
  different templates (phisically placed in diffrent locations)
  and I think that my templates were mixed between my applications?

  in the .loadConfiguration() method of the servlet I set path for template engine:

    String path = config.getServletContext().getRealPath("/");
    p.setProperty( Velocity.FILE_RESOURCE_LOADER_PATH,  path );
  

  So, I think my question is: How to use separate schema of loading
  templates in servlet that extends VelocityServlet?

  Is there other ways than renaming templates directories in every application to
  make them unique?

  Could anyone help me? Perhaps, problem in my servlet?

  Thank you.
  Anton Melehin.
-- 
Best regards,
 Melehin                          mailto:melehin_anton@mail.ru



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re[2]: a problem with template loading

Posted by Melehin Anton <me...@mail.ru>.
Hello Anthony,

Sunday, March 10, 2002, 9:47:45 PM, you wrote:

AE> Do you have a separate Velocity JAR for each WAR or are you sharing a
AE> single JAR throughout Tomcat?  If you have a separate Velocity JAR in
AE> each WAR then I think that this problem would not occur.

AE> Sincerely,
AE> Anthony Eden

Thank you for answer.

Perhaps it's a way for me. I'll try...BUT

I didn't tell that I want to use many instances of this servlet in one
application (with diffrent settings for every servlet and diffrent templates for some of them)...

That's because I think that this decision don't match for me and I'll
meet the same problem... Am I right?

But If your decision work, there is another problem which I can decide:
suppose, I have three servlet:
/a
/b
/c

every have it's own templateroot
/tmpl/a/html/
/tmpl/b/html/
/tmpl/c/html/
can I use them in one application without using TemplateEngine?

Now I think that I have to make
one root /tmpl/ for an application and set servlet to use it's own
sub-root (/a,/b,/c).

The problem is that I have to change every template to use that new root
(not /html but /a/html). Templates have to be changed because they
include #parse directive which must have the same root that was set in
servlet. So for servlet 'a' there will be #parse (/a/html/) for b
(/b/html/) ...)

Another way for me -- just use TemplateEngine and make my own
base servlet (which will differ from VelocityServlet)...
Can TemplateEngine work in that way (many instances (10-20) of TemplateEngine in
one application)? Or it will spend a large amount of memory?

Which way is right?

-- 
Best regards,
Anton Melehin                            mailto:melehin_anton@mail.ru



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: a problem with template loading

Posted by Anthony Eden <ae...@signaturedomains.com>.
Do you have a separate Velocity JAR for each WAR or are you sharing a
single JAR throughout Tomcat?  If you have a separate Velocity JAR in
each WAR then I think that this problem would not occur.

Sincerely,
Anthony Eden

> -----Original Message-----
> From: Melehin Anton [mailto:melehin_anton@mail.ru] 
> Sent: Sunday, March 10, 2002 11:13 AM
> To: velocity-user@jakarta.apache.org
> Subject: a problem with template loading
> 
> 
> Hello All.
> 
>   I'm using Velocity 1.2 for 1 week.
> 
>   Yesterday, I've finished a simple servlet that uses 
> VelocityServlet as base
>   class. This servlet use 10 templates for its work. It
>   load them by calling method getTemplate (for example 
> getTemplate('html/show.vm.html') )
>   of  VelocityServlet.
> 
>   When I deployed it to the test application, almost 
> everything were fine for me.
> 
>   After that, I decided to deploy this servlet to my
>   web-applications. I put servlet settings to the web.xml in 3
>   other web-applications.
> 
>   There are separate templates for every
>   applications. So in every .war were separate copy of my templates
>   (html/). I made 3 .war and deployed them to the Tomcat 
> 3.2.2. Everything
>   were Ok, until I decided to change template in one of applications.
>   I can see those changes in other applications!
> 
>   After that I read docs and understood that Velocity can use two
>   'schemas' of using templates:
>   1.one engine for JVM
>   2.separate engine for every application.
> 
>   Every servlet instance use same name ('html/show.vm.html') for
>   different templates (phisically placed in diffrent locations)
>   and I think that my templates were mixed between my applications?
> 
>   in the .loadConfiguration() method of the servlet I set 
> path for template engine:
> 
>     String path = config.getServletContext().getRealPath("/");
>     p.setProperty( Velocity.FILE_RESOURCE_LOADER_PATH,  path );
>   
> 
>   So, I think my question is: How to use separate schema of loading
>   templates in servlet that extends VelocityServlet?
> 
>   Is there other ways than renaming templates directories in 
> every application to
>   make them unique?
> 
>   Could anyone help me? Perhaps, problem in my servlet?
> 
>   Thank you.
>   Anton Melehin.
> -- 
> Best regards,
>  Melehin                          mailto:melehin_anton@mail.ru
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:velocity-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>