velocity-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Mutschlechner" <S.Mutschlech...@uts-italia.it>
Subject Probelm with template
Date Wed, 28 May 2008 08:22:00 GMT
I'm really new by working with velocity, and servelets.

I'm able to start function witch uses a template to create a html code.

 

 

try 

      {

              /*  first, get and initialize an engine  */

              VelocityEngine ve = new VelocityEngine();

              //ve.init("C:/Programme/Apache Software Foundation/Tomcat
6.0/webapps/examples/WEB-INF/classes/velocity.properties");

              ve.init();      

              /*  next, get the Template  */

              if(ve.templateExists(strtmp))

              {

                  str="Template found !!!!!";

              }

              else

              {

                  str="Template not  found !!!!!";

              }

              Template t = ve.getTemplate(strtmp );

              /*  create a context and add data */

              VelocityContext context = new VelocityContext();

              context.put("name", "World");

              /* now render the template into a StringWriter */

              

              t.merge( context, writer );

              /* show the World */

             // System.out.println( writer.toString() ); 

      }

        catch (Exception e) 

          {

            System.out.print("Error"+ e+"\n");

          }

 

 

 

 

If I have the same source code into a servelet, the servlet don't find
the 

Template.

 

Somebody knows where I can find a small example for this???

I have found more solutions one different websites.

I have tried more of this solutions and its not working.

 

Thanks

 

Stefan Mutschlechner


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message