You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Markus <ma...@gmx.com> on 2004/02/05 15:06:16 UTC

velocitytools and struts

Hi 
Sorry for crossposting!
I've tried in the struts user list, but later I find others which failed
there too!

I've tried to install velocity with struts.
I followed the installation instructions from velocity.
Put velocity-1.3.1.jar and velocity-tools-1.1-beta1.jar in my lib.
copied toolbox.xml and velocity.properties in my WEB-INF
canged web.xml to
<snip>

 <servlet>
    <servlet-name>velocity</servlet-name>
  

<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
    <init-param>
        <param-name>toolbox</param-name>
        <param-value>/WEB-INF/toolbox.xml</param-value>
    </init-param>
    <load-on-startup>10</load-on-startup>
  </servlet>
...
<servlet-mapping>
    <servlet-name>velocity</servlet-name>
    <url-pattern>*.vm</url-pattern>
  </servlet-mapping>

</snip>
and I've writen the following velocitypage:

<html>
    <head>
        <title>First Velocitypage</title>
    </head>
    <body>
        #set ($hello="Dies ist meine erste Velocitypage")
        $hello<br/>
        $msg.get("hello")<br/>
        $msg.exists("hello")<br/>
        
    </body>
</html>

velocityservlet renders $hello but it did not find the message 
the ressources to the messages is right, I've tested it with a JSP

Any suggestions?

Kind regards,
Markus




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


Re: velocitytools and struts

Posted by Markus <ma...@gmx.com>.
Thank you!
Now it works!

Kind regards, 
Markus

> Markus,
> It has to look like this, I think some docs need to be changed somewhere.
> 
>
---------------------------------------------------------------------------------------
>     <!-- Define struts action servlet to handle all .do requests -->
>     <servlet>
>         <servlet-name>action</servlet-name>
>         
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>         <init-param>
>             <param-name>config</param-name>
>             <param-value>/WEB-INF/conf/struts-config.xml</param-value>
>         </init-param>
>         <init-param>
>             <param-name>debug</param-name>
>             <param-value>2</param-value>
>         </init-param>
>         <init-param>
>             <param-name>detail</param-name>
>             <param-value>2</param-value>
>         </init-param>
>         <load-on-startup>10</load-on-startup>
>     </servlet>
>     <!-- Define Velocity template rendererr -->
>     <servlet>
>         <servlet-name>velocity</servlet-name>
>         
>
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityLayoutServlet</servlet-class>
>         <init-param>
>             <param-name>org.apache.velocity.properties</param-name>
>             <param-value>/WEB-INF/conf/velocity.properties</param-value>
>         </init-param>
>         <init-param>
>             <param-name>org.apache.velocity.toolbox</param-name>
>             <param-value>/WEB-INF/conf/toolbox.xml</param-value>
>         </init-param>
>         <load-on-startup>20</load-on-startup>
>     </servlet>
> 
>     <!-- Map *.vm calls to Velocity -->
>     <servlet-mapping>
>         <servlet-name>velocity</servlet-name>
>         <url-pattern>*.vm</url-pattern>
>     </servlet-mapping>
>     <!-- Map *.do calls to Struts -->
>     <servlet-mapping>
>         <servlet-name>action</servlet-name>
>         <url-pattern>*.do</url-pattern>
>     </servlet-mapping>
>
---------------------------------------------------------------------------------------
> 
> Hope that helps.
> 
> Charlie
> 
> 
> 
> Markus wrote:
> 
> >Hi 
> >Sorry for crossposting!
> >I've tried in the struts user list, but later I find others which failed
> >there too!
> >
> >I've tried to install velocity with struts.
> >I followed the installation instructions from velocity.
> >Put velocity-1.3.1.jar and velocity-tools-1.1-beta1.jar in my lib.
> >copied toolbox.xml and velocity.properties in my WEB-INF
> >canged web.xml to
> ><snip>
> >
> > <servlet>
> >    <servlet-name>velocity</servlet-name>
> >  
> >
>
><servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
> >    <init-param>
> >        <param-name>toolbox</param-name>
> >        <param-value>/WEB-INF/toolbox.xml</param-value>
> >    </init-param>
> >    <load-on-startup>10</load-on-startup>
> >  </servlet>
> >...
> ><servlet-mapping>
> >    <servlet-name>velocity</servlet-name>
> >    <url-pattern>*.vm</url-pattern>
> >  </servlet-mapping>
> >
> ></snip>
> >and I've writen the following velocitypage:
> >
> ><html>
> >    <head>
> >        <title>First Velocitypage</title>
> >    </head>
> >    <body>
> >        #set ($hello="Dies ist meine erste Velocitypage")
> >        $hello<br/>
> >        $msg.get("hello")<br/>
> >        $msg.exists("hello")<br/>
> >        
> >    </body>
> ></html>
> >
> >velocityservlet renders $hello but it did not find the message 
> >the ressources to the messages is right, I've tested it with a JSP
> >
> >Any suggestions?
> >
> >Kind regards,
> >Markus
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >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
> 


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


Re: velocitytools and struts

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
Markus,
It has to look like this, I think some docs need to be changed somewhere.

---------------------------------------------------------------------------------------
    <!-- Define struts action servlet to handle all .do requests -->
    <servlet>
        <servlet-name>action</servlet-name>
        
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/conf/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>2</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>2</param-value>
        </init-param>
        <load-on-startup>10</load-on-startup>
    </servlet>
    <!-- Define Velocity template rendererr -->
    <servlet>
        <servlet-name>velocity</servlet-name>
        
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityLayoutServlet</servlet-class>
        <init-param>
            <param-name>org.apache.velocity.properties</param-name>
            <param-value>/WEB-INF/conf/velocity.properties</param-value>
        </init-param>
        <init-param>
            <param-name>org.apache.velocity.toolbox</param-name>
            <param-value>/WEB-INF/conf/toolbox.xml</param-value>
        </init-param>
        <load-on-startup>20</load-on-startup>
    </servlet>

    <!-- Map *.vm calls to Velocity -->
    <servlet-mapping>
        <servlet-name>velocity</servlet-name>
        <url-pattern>*.vm</url-pattern>
    </servlet-mapping>
    <!-- Map *.do calls to Struts -->
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
---------------------------------------------------------------------------------------

Hope that helps.

Charlie



Markus wrote:

>Hi 
>Sorry for crossposting!
>I've tried in the struts user list, but later I find others which failed
>there too!
>
>I've tried to install velocity with struts.
>I followed the installation instructions from velocity.
>Put velocity-1.3.1.jar and velocity-tools-1.1-beta1.jar in my lib.
>copied toolbox.xml and velocity.properties in my WEB-INF
>canged web.xml to
><snip>
>
> <servlet>
>    <servlet-name>velocity</servlet-name>
>  
>
><servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
>    <init-param>
>        <param-name>toolbox</param-name>
>        <param-value>/WEB-INF/toolbox.xml</param-value>
>    </init-param>
>    <load-on-startup>10</load-on-startup>
>  </servlet>
>...
><servlet-mapping>
>    <servlet-name>velocity</servlet-name>
>    <url-pattern>*.vm</url-pattern>
>  </servlet-mapping>
>
></snip>
>and I've writen the following velocitypage:
>
><html>
>    <head>
>        <title>First Velocitypage</title>
>    </head>
>    <body>
>        #set ($hello="Dies ist meine erste Velocitypage")
>        $hello<br/>
>        $msg.get("hello")<br/>
>        $msg.exists("hello")<br/>
>        
>    </body>
></html>
>
>velocityservlet renders $hello but it did not find the message 
>the ressources to the messages is right, I've tested it with a JSP
>
>Any suggestions?
>
>Kind regards,
>Markus
>
>
>
>
>---------------------------------------------------------------------
>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: velocitytools and struts

Posted by Claude Brisson <cl...@savoirweb.com>.
>         <param-name>toolbox</param-name>

try <param-name>org.apache.velocity.toolbox</param-name>

----- Original Message ----- 
From: "Markus" <ma...@gmx.com>
To: <ve...@jakarta.apache.org>
Sent: Thursday, February 05, 2004 3:06 PM
Subject: velocitytools and struts


> Hi 
> Sorry for crossposting!
> I've tried in the struts user list, but later I find others which failed
> there too!
> 
> I've tried to install velocity with struts.
> I followed the installation instructions from velocity.
> Put velocity-1.3.1.jar and velocity-tools-1.1-beta1.jar in my lib.
> copied toolbox.xml and velocity.properties in my WEB-INF
> canged web.xml to
> <snip>
> 
>  <servlet>
>     <servlet-name>velocity</servlet-name>
>   
> 
> <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
>     <init-param>
>         <param-name>toolbox</param-name>
>         <param-value>/WEB-INF/toolbox.xml</param-value>
>     </init-param>
>     <load-on-startup>10</load-on-startup>
>   </servlet>
> ...
> <servlet-mapping>
>     <servlet-name>velocity</servlet-name>
>     <url-pattern>*.vm</url-pattern>
>   </servlet-mapping>
> 
> </snip>
> and I've writen the following velocitypage:
> 
> <html>
>     <head>
>         <title>First Velocitypage</title>
>     </head>
>     <body>
>         #set ($hello="Dies ist meine erste Velocitypage")
>         $hello<br/>
>         $msg.get("hello")<br/>
>         $msg.exists("hello")<br/>
>         
>     </body>
> </html>
> 
> velocityservlet renders $hello but it did not find the message 
> the ressources to the messages is right, I've tested it with a JSP
> 
> Any suggestions?
> 
> Kind regards,
> Markus
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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: velocitytools and struts

Posted by Mike Kienenberger <mk...@alaska.net>.
Markus <ma...@gmx.com> wrote:
>  <servlet>
>     <servlet-name>velocity</servlet-name>
>   
> 
> <servlet-class>
org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
>     <init-param>
>         <param-name>toolbox</param-name>
>         <param-value>/WEB-INF/toolbox.xml</param-value>
>     </init-param>
>     <load-on-startup>10</load-on-startup>
>   </servlet>

I use this.  Note that the param-name for toolbox is different in yours, and 
you have no definition for properties.

	<servlet>
	  <servlet-name>velocity</servlet-name>
	  <servlet-class>
	    org.apache.velocity.tools.view.servlet.VelocityLayoutServlet
	  </servlet-class>
	
	  <init-param>
	    <param-name>org.apache.velocity.toolbox</param-name>
	    <param-value>/WEB-INF/toolbox.xml</param-value>
	 </init-param>
	
	  <init-param>
	    <param-name>org.apache.velocity.properties</param-name>
	    <param-value>/WEB-INF/velocity.properties</param-value>
	 </init-param>
	 <load-on-startup>10</load-on-startup>
	</servlet>


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