You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Stephen Riek <st...@yahoo.co.uk> on 2002/05/04 22:12:06 UTC

Overhead creating a Vector of objects to send to VTL ? ( Re: foreach)

I work solely in the Web world. Probably the most common place where 
one would use #foreach is looping over a list of results from a query.
For example, viewing a catalog, or viewing the results from a search
engine. I have never found Velocity lacking, mainly because I've 
usually handled all the logic in the SQL before I return the list of
results to Velocity.  
Consider sending the results of a SQL query to a velocity template. 
Each result represents an object (eg. an item in your catalog) for
which you have a corresponding Javabean. At the moment I loop over
the JDBC ResultSet within the Java code and create a Vector of 
catalogItem objects, which is sent to the Velocity Template. 
This contrasts greatly with the JSP way of handling the JDBC ResultSet
directly. However, is my mechanism using too much Object creation
(the Vector of Javabeans) which I understand is "expensive" overhead
in Java ?I'm trying to optimize performance and scalability so is this a 
real concern ? 

I have never bought into the "most people working in the MVC View 
are not programmers" argument, which is the basis of Struts and a 
multitude of frameworks which seem to have been born in ivory towers.  
Sure, it's true there are more non-programmers in the View area, but I 
wouldn't expect any designer to be able to use VTL. No disrespect to 
any of them, but the hundreds of designers I've worked with just wouldn't 
want to know and prefer not to have the responsibility. Therefore, 
it's a non-issue for me.  Velocity Rocks.

Thank you for any feedback on the initial question.
Stephen Riek.
 



---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.

Re: Overhead creating a Vector of objects to send to VTL ? ( Re: foreach)

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/4/02 4:12 PM, "Stephen Riek" <st...@yahoo.co.uk> wrote:

> 
> I work solely in the Web world. Probably the most common place where
> one would use #foreach is looping over a list of results from a query.
> For example, viewing a catalog, or viewing the results from a search
> engine. I have never found Velocity lacking, mainly because I've
> usually handled all the logic in the SQL before I return the list of
> results to Velocity.
> Consider sending the results of a SQL query to a velocity template.
> Each result represents an object (eg. an item in your catalog) for
> which you have a corresponding Javabean. At the moment I loop over
> the JDBC ResultSet within the Java code and create a Vector of
> catalogItem objects, which is sent to the Velocity Template.
> This contrasts greatly with the JSP way of handling the JDBC ResultSet
> directly. However, is my mechanism using too much Object creation
> (the Vector of Javabeans) which I understand is "expensive" overhead
> in Java ?I'm trying to optimize performance and scalability so is this a
> real concern ? 

If you are not accessing everything in the result set, this may be wasteful
(although java is getting efficient).

One solution is to access the data 'just in time'.  To do this, make a
little class that you put the result set into, and then that class into the
context. It might be a little  bit of a pain as you will need to let
Velocity iterator over something.  If you only will iterate over it once,
then you can just make it look like an Iterator.  I have no idea if the
following works, let alone compiles.  I am just making this up :)

 public class Foo implements java.util.Iterator {

    ResultSet myResultSet;
    MyMapper mapper;

    public Foo(ResultSet rs)
    {
        myResultSet = rs;
        mapper = new Mapper(myResultSet);
    }

     public boolean hasNext() {
       
        return rs.next();
     }

     public Object next() {
          return mapper;
     }
}

 public class MyMapper implements Map{
   ResultSet rs;

  public MyMapper(ResultSet rs)
  {
      this.rs = rs;
   }
  
   public Object get(String key)
   {
     return rs.getString(key);
   }

   ... Rest of Map methods
}


So the idea is that you wrap the result set in something that looks like a
java.util.Iterator, so Vel will iterate over it and put that into the
context.  No new objects yet.

Then, each item in the set will be a mapper that also wraps the result set
(so no new objects created).

Then, when you use it

  #foreach($item in $resultset)

      $item.foo

  #end

Will only access the result set creating a string for the column 'foo'.


> 
> I have never bought into the "most people working in the MVC View
> are not programmers" argument, which is the basis of Struts and a
> multitude of frameworks which seem to have been born in ivory towers.
> Sure, it's true there are more non-programmers in the View area, but I
> wouldn't expect any designer to be able to use VTL. No disrespect to
> any of them, but the hundreds of designers I've worked with just wouldn't
> want to know and prefer not to have the responsibility. Therefore,
> it's a non-issue for me.  Velocity Rocks.
> 
> Thank you for any feedback on the initial question.
> Stephen Riek.
> 
> 
> 
> 
> ---------------------------------
> Do You Yahoo!?
> Get personalised at My Yahoo!.
> 

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: Problem loading templates into Javabeans.

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/5/02 2:36 AM, "Stephen Riek" <st...@yahoo.co.uk> wrote:

> 
>>>   "Geir Magnusson Jr." <ge...@adeptra.com> wrote:
>>> Thank you for the explanation Geir. Using your method
>>> the Javabean can load the template OK when used in a
>>> standalone Java app but it still isn't loaded when
>>> used in a webapp.
>>> 1. The template is placed in
>>> /WEB-INF/classes/com/fubar/template.vm
>> 
>> Keep the template in the jar, and throw the whole jar into
>> 
>> WEB-INF/lib
>> 
>> Is that going to be a problem? I don't know how you are
>> deploying, but I would figure this would be the most
>> convenient thing - one jar, one config, two uses....
> Yes, that will be most convenient for deployment but during
> the development process it's necessary to keep changing or
> tweaking the template.vm and the actual Javabean code.
> I love Velocity for the rapid prototyping. Change the template.vm
> and see the results instantly. Continually repacking a jar
> and waiting for Tomcat to reload introduces the same sort of
> delays that I dislike with JSP.
> Still, if there's no other way, I'll do all development of
> the Javabean in standalone mode and then when I'm happy with
> the code, pack a jar and stick it in the WEB-INF/lib.
> Would be nicer to prototype within the webapp though.

Hm.  I wonder if you could rig it such that you have both file and
classloader going at the same time.  The only problem would be to set the
file path.  Hm.  You could do '/' but that's yecchy and dangerous, as if you
deploy that way, you aren't in control of what will happen.

Good problem.

> Thanks for the help Geir. Does this man ever sleep ?

Actually headed there right now :)

Thanks

> Stephen Riek
> 
>> 2. The Javabean that uses the template is
>> /WEB-INF/classes/com/fubar/VBean.java
>> 3. VBean.java has the display() method below which gets a template file
>> (template.vm) 
>> and returns a string. It will obviously also put variables in the context
>> later.
>> public String display() {
>> try {
>> Template template=null;
>> Velocity.setProperty("resource.loader", "class");
>> 
>> 
Velocity.setProperty("class.resource.loader.class","org.apache.velocity.runti>>
m
>> e.resource.loader.ClasspathResourceLoader" );
>> Velocity.init();
>> System.out.println("debug = velocity.init() ok");
>> Template t = Velocity.getTemplate("com/fubar/template.vm");
>> System.out.println("debug = got the template ok");
>> VelocityContext context = new VelocityContext();
>> System.out.println("debug = created context");
>> StringWriter sw = new StringWriter();
>> template.merge( context, sw );
>> System.out.println("debug = merged ok");
>> return sw.toString();
>> }
>> catch( ResourceNotFoundException rnfe ) {
>> System.out.println("debug = template not found");
>> }
>> catch( ParseErrorException pee ) { }
>> catch( MethodInvocationException mie ) { }
>> catch( Exception e ){
>> System.out.println("Unexpected Error " + e.getMessage());
>> }
>> return "";
>> }
>> 
>> When the Javabean is used in a standalone Java application, template.vm is
>> loaded OK*. 
>> However, when the Javabean is created from a JSP and the display() method
>> called,
>> the "template not found" debug message is shown in the Tomcat shell.
>> 
>> * Even when the template is loaded correctly in the standalone app, it fails
>> to 
>> merge and generates "Unexpected Error null" but that's a different problem.
>> 
>> I like this method of template loading and can't help but feel I'm almost
>> there
>> but having gone round in circles for a hours testing different settings can't
>> seem to get it. 
>> 
> 
> 
> 
> ---------------------------------
> Do You Yahoo!?
> Get personalised at My Yahoo!.
> 

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: Problem loading templates into Javabeans.

Posted by Stephen Riek <st...@yahoo.co.uk>.
> >   "Geir Magnusson Jr." <ge...@adeptra.com> wrote: 
> > Thank you for the explanation Geir. Using your method 
> > the Javabean can load the template OK when used in a 
> > standalone Java app but it still isn't loaded when
> > used in a webapp. 
> > 1. The template is placed in
> > /WEB-INF/classes/com/fubar/template.vm
> 
> Keep the template in the jar, and throw the whole jar into
> 
> WEB-INF/lib
> 
> Is that going to be a problem? I don't know how you are 
> deploying, but I would figure this would be the most 
> convenient thing - one jar, one config, two uses....
Yes, that will be most convenient for deployment but during
the development process it's necessary to keep changing or
tweaking the template.vm and the actual Javabean code. 
I love Velocity for the rapid prototyping. Change the template.vm
and see the results instantly. Continually repacking a jar
and waiting for Tomcat to reload introduces the same sort of
delays that I dislike with JSP.
Still, if there's no other way, I'll do all development of
the Javabean in standalone mode and then when I'm happy with
the code, pack a jar and stick it in the WEB-INF/lib.
Would be nicer to prototype within the webapp though.
Thanks for the help Geir. Does this man ever sleep ?
Stephen Riek

> 2. The Javabean that uses the template is
> /WEB-INF/classes/com/fubar/VBean.java
> 3. VBean.java has the display() method below which gets a template file
> (template.vm) 
> and returns a string. It will obviously also put variables in the context
> later.
> public String display() {
> try {
> Template template=null;
> Velocity.setProperty("resource.loader", "class");
> 
> Velocity.setProperty("class.resource.loader.class","org.apache.velocity.runtim
> e.resource.loader.ClasspathResourceLoader" );
> Velocity.init();
> System.out.println("debug = velocity.init() ok");
> Template t = Velocity.getTemplate("com/fubar/template.vm");
> System.out.println("debug = got the template ok");
> VelocityContext context = new VelocityContext();
> System.out.println("debug = created context");
> StringWriter sw = new StringWriter();
> template.merge( context, sw );
> System.out.println("debug = merged ok");
> return sw.toString();
> }
> catch( ResourceNotFoundException rnfe ) {
> System.out.println("debug = template not found");
> }
> catch( ParseErrorException pee ) { }
> catch( MethodInvocationException mie ) { }
> catch( Exception e ){
> System.out.println("Unexpected Error " + e.getMessage());
> }
> return "";
> }
> 
> When the Javabean is used in a standalone Java application, template.vm is
> loaded OK*. 
> However, when the Javabean is created from a JSP and the display() method
> called,
> the "template not found" debug message is shown in the Tomcat shell.
> 
> * Even when the template is loaded correctly in the standalone app, it fails
> to 
> merge and generates "Unexpected Error null" but that's a different problem.
> 
> I like this method of template loading and can't help but feel I'm almost
> there
> but having gone round in circles for a hours testing different settings can't
> seem to get it. 
> 



---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.

Re: Problem loading templates into Javabeans.

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/5/02 1:00 AM, "Stephen Riek" <st...@yahoo.co.uk> wrote:

> 
> Thank you for the explanation Geir.  Using your method the Javabean can load
> the
> template OK when used in a standalone Java app but it still isn't loaded when
> used
> in a webapp. 
> 1. The template is placed in
> <webapp>/WEB-INF/classes/com/fubar/template.vm

Keep the template in the jar, and throw the whole jar into

  WEB-INF/lib

Is that going to be a problem?  I don't know how you are deploying, but I
would figure this would be the most convenient thing - one jar, one config,
two uses....


> 
> 2. The Javabean that uses the template is
> <webapp>/WEB-INF/classes/com/fubar/VBean.java
> 3. VBean.java has the display() method below which gets a template file
> (template.vm) 
> and returns a string. It will obviously also put variables in the context
> later.
> public String display() {
> try {
>  Template template=null;
>  Velocity.setProperty("resource.loader", "class");
>  
> Velocity.setProperty("class.resource.loader.class","org.apache.velocity.runtim
> e.resource.loader.ClasspathResourceLoader" );
>  Velocity.init();
>  System.out.println("debug = velocity.init() ok");
>  Template t = Velocity.getTemplate("com/fubar/template.vm");
>  System.out.println("debug = got the template ok");
>  VelocityContext context = new VelocityContext();
>  System.out.println("debug = created context");
>  StringWriter sw = new StringWriter();
>  template.merge( context, sw );
>  System.out.println("debug = merged ok");
>  return  sw.toString();
> }
> catch( ResourceNotFoundException rnfe ) {
>     System.out.println("debug = template not found");
>  }
> catch( ParseErrorException pee ) { }
> catch( MethodInvocationException mie ) { }
> catch( Exception e ){
>  System.out.println("Unexpected Error " + e.getMessage());
> }
> return "";
> }
> 
> When the Javabean is used in a standalone Java application, template.vm is
> loaded OK*. 
> However, when the Javabean is created from a JSP and the display() method
> called,
> the "template not found" debug message is shown in the Tomcat shell.
> 
> * Even when the template is loaded correctly in the standalone app, it fails
> to 
> merge and generates "Unexpected Error null" but that's a different problem.
> 
> I like this method of template loading and can't help but feel I'm almost
> there
> but having gone round in circles for a hours testing different settings can't
> seem to get it. 
> 
> Stephen Riek.
> 
> 
> 
> 
> ---------------------------------
> Do You Yahoo!?
> Get personalised at My Yahoo!.
> 

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: Problem loading templates into Javabeans.

Posted by Stephen Riek <st...@yahoo.co.uk>.
 Thank you for the explanation Geir.  Using your method the Javabean can load the
template OK when used in a standalone Java app but it still isn't loaded when used
in a webapp. 
1. The template is placed in 
<webapp>/WEB-INF/classes/com/fubar/template.vm

2. The Javabean that uses the template is 
<webapp>/WEB-INF/classes/com/fubar/VBean.java
3. VBean.java has the display() method below which gets a template file (template.vm) 
and returns a string. It will obviously also put variables in the context later.
public String display() {
  try {
   Template template=null;
   Velocity.setProperty("resource.loader", "class");
   Velocity.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" );
   Velocity.init();
   System.out.println("debug = velocity.init() ok");
   Template t = Velocity.getTemplate("com/fubar/template.vm");
   System.out.println("debug = got the template ok");
   VelocityContext context = new VelocityContext();
   System.out.println("debug = created context");
   StringWriter sw = new StringWriter();
   template.merge( context, sw );
   System.out.println("debug = merged ok");
   return  sw.toString();
  }
  catch( ResourceNotFoundException rnfe ) {   
      System.out.println("debug = template not found");
   }
  catch( ParseErrorException pee ) { }
  catch( MethodInvocationException mie ) { }
  catch( Exception e ){
   System.out.println("Unexpected Error " + e.getMessage());
  }
  return "";
 }

When the Javabean is used in a standalone Java application, template.vm is loaded OK*. 
However, when the Javabean is created from a JSP and the display() method called,
the "template not found" debug message is shown in the Tomcat shell.

* Even when the template is loaded correctly in the standalone app, it fails to 
merge and generates "Unexpected Error null" but that's a different problem. 

I like this method of template loading and can't help but feel I'm almost there
but having gone round in circles for a hours testing different settings can't 
seem to get it. 

Stephen Riek.




---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.

Re: Problem loading templates into Javabeans.

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/4/02 6:01 PM, "Stephen Riek" <st...@yahoo.co.uk> wrote:

> 
> At the risk of appearing an idiot or lazy, which I'd like to think I'm not,
> an example would be very helpful. I've had a lot of problems configuring
> Tomcat to date. I had even tried to set a parameter in web.xml that would
> specify the filepath of the template.vm but couldn't get that to work even.
> The Tomcat group could do with a helping hand from whoever wrote the
> Velocity documentation :-)
> 

:)

Ok - the following should work :

1) put the template in your jar.  'Top level' is fine, but you might want to
be safe via something deeper.

  foo/bar/woogie/yourtemplate.vm

2) Configure velocity.  Can be via properties or directly.  Direct example :


  Velocity.setProperty("resource.loader", "class");
  Velocity.setProperty("class.resource.loader.class",
    "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" );

  ... Set any other properties ...

  Velocity.init();

And you probably should use Velocity.RESOURCE_LOADER instead of the strings
:)

That *should* do it - you will have to then

  Template t = Velocity.getTemplate("foo/bar/woogie/yourtemplate.vm");

So be forewarned.

Should work just fine.

Geir


> Stephen Riek.
> 
> 
> 
> "Geir Magnusson Jr." <ge...@adeptra.com> wrote:
> On 5/4/02 5:26 PM, "Stephen Riek" wrote:
> 
>> 
>>> "Geir Magnusson Jr." wrote:
>>> I don't understand the question.
>> 
>> Sorry :(
>> 
>>> Do you want to make a javabean that embeds Velocity?
>> 
>> That is correct.
>> 
>> public class VBean {
>> // snipped Constructor and
>> // setXxx() and getXxx() methods.
>> 
>> public render() {
>> // load template.vm from file system.
>> // put all properties in a Velocity context.
>> // return result.
>> } 
>> } 
>> 
>> I created a bean that loads the template.vm from the
>> current directory
>> The problem is specifying the location of template.vm
>> if the Javabean is to be used in Tomcat webapps by
>> servlets and JSPs.
> 
> Oh - easy.
> 
> Use the classpath loader, and put the template in the jar you ship the bean
> in.
> 
> If that's not clear, I can give an example.
> 

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: Problem loading templates into Javabeans.

Posted by Stephen Riek <st...@yahoo.co.uk>.
 At the risk of appearing an idiot or lazy, which I'd like to think I'm not, 
an example would be very helpful. I've had a lot of problems configuring
Tomcat to date. I had even tried to set a parameter in web.xml that would
specify the filepath of the template.vm but couldn't get that to work even.
The Tomcat group could do with a helping hand from whoever wrote the 
Velocity documentation :-)

Stephen Riek.

 

  "Geir Magnusson Jr." <ge...@adeptra.com> wrote: 
On 5/4/02 5:26 PM, "Stephen Riek" wrote:

> 
>> "Geir Magnusson Jr." wrote:
>> I don't understand the question.
> 
> Sorry :(
> 
>> Do you want to make a javabean that embeds Velocity?
> 
> That is correct. 
> 
> public class VBean {
> // snipped Constructor and
> // setXxx() and getXxx() methods.
> 
> public render() {
> // load template.vm from file system.
> // put all properties in a Velocity context.
> // return result.
> } 
> } 
> 
> I created a bean that loads the template.vm from the
> current directory
> The problem is specifying the location of template.vm
> if the Javabean is to be used in Tomcat webapps by
> servlets and JSPs.

Oh - easy.

Use the classpath loader, and put the template in the jar you ship the bean
in.

If that's not clear, I can give an example.


-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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



---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.

Re: Problem loading templates into Javabeans.

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/4/02 5:26 PM, "Stephen Riek" <st...@yahoo.co.uk> wrote:

> 
>> "Geir Magnusson Jr." <ge...@adeptra.com> wrote:
>> I don't understand the question.
> 
> Sorry :(
> 
>> Do you want to make a javabean that embeds Velocity?
> 
> That is correct. 
> 
> public class VBean {
>   // snipped Constructor and
>   // setXxx() and getXxx() methods.
> 
>   public render() {
>      // load template.vm from file system.
>      // put all properties in a Velocity context.
>      // return result.
>   } 
> } 
> 
> I created a bean that loads the template.vm from the
> current directory
> The problem is specifying the location of template.vm
> if the Javabean is to be used in Tomcat webapps by
> servlets and JSPs.

Oh - easy.

Use the classpath loader, and put the template in the jar you ship the bean
in.

If that's not clear, I can give an example.


-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: Problem loading templates into Javabeans.

Posted by Stephen Riek <st...@yahoo.co.uk>.
> "Geir Magnusson Jr." <ge...@adeptra.com> wrote: 
> I don't understand the question.

Sorry :(

> Do you want to make a javabean that embeds Velocity?

That is correct. 

public class VBean { 
    // snipped Constructor and 
    // setXxx() and getXxx() methods.

    public render() { 
       // load template.vm from file system.
       // put all properties in a Velocity context.
       // return result.
    } 
} 

I created a bean that loads the template.vm from the 
current directory 
The problem is specifying the location of template.vm
if the Javabean is to be used in Tomcat webapps by 
servlets and JSPs. 

Stephen Riek.

>> I have encountered a problem defining a File Resource Loader for a
>> Javabean which will be used in a webapp as well as a standalone
>> application. Since it is a Javabean that may be used outside of the
>> Tomcat JVM, I can not rely on the servlet context. I had it working
>> with a Javabean in standalone code using a velocity.properties file
>> and template.vm in the working directory or hardcoded into the
>> Javabean but both caused a resource not found error when the
>> Javabean was called from a JSP.
>> Veltags is not really what I'm looking for because I'm again using
>> the Javabean outside of the webapp.
>> 
>> Is this possible at all ? Really, I'd like to ship just a Javabean plus
>> one template.vm and maybe a velocity.properties file, that can be
>> used within webapp as well as standalone apps. Too much to ask ?





---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.

Re: Problem loading templates into Javabeans.

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 5/4/02 4:22 PM, "Stephen Riek" <st...@yahoo.co.uk> wrote:

> 
> I have encountered a problem defining a File Resource Loader for a
> Javabean which will be used in a webapp as well as a standalone
> application. Since it is a Javabean that may be used outside of the
> Tomcat JVM, I can not rely on the servlet context. I had it working
> with a Javabean in standalone code using a velocity.properties file
> and template.vm in the working directory or hardcoded into the
> Javabean but both caused a resource not found error when the
> Javabean was called from a JSP.
> Veltags is not really what I'm looking for because I'm again using
> the Javabean outside of the webapp.
> 
> Is this possible at all ? Really, I'd like to ship just a Javabean plus
> one template.vm and maybe a velocity.properties file, that can be
> used within webapp as well as standalone apps. Too much to ask ?
> 

I don't understand the question.

Do you want to make a javabean that embeds Velocity?

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Problem loading templates into Javabeans.

Posted by Stephen Riek <st...@yahoo.co.uk>.
I have encountered a problem defining a File Resource Loader for a 
Javabean which will be used in a webapp as well as a standalone 
application. Since it is a Javabean that may be used outside of the
Tomcat JVM, I can not rely on the servlet context. I had it working
with a Javabean in standalone code using a velocity.properties file
and template.vm in the working directory or hardcoded into the 
Javabean but both caused a resource not found error when the 
Javabean was called from a JSP. 
Veltags is not really what I'm looking for because I'm again using
the Javabean outside of the webapp. 

Is this possible at all ? Really, I'd like to ship just a Javabean plus
one template.vm and maybe a velocity.properties file, that can be
used within webapp as well as standalone apps. Too much to ask ?

Stephen Riek.



---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.