You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by si...@apache.org on 2002/04/04 15:05:57 UTC
cvs commit: jakarta-velocity-tools/view/src/java/org/apache/velocity/tools/view/servlet VelocityViewServlet.java
sidler 02/04/04 05:05:57
Modified: struts/examples/struts/WEB-INF web.xml
view/src/java/org/apache/velocity/tools/view/servlet
VelocityViewServlet.java
Log:
Modified VelocityViewServlet to load configuration using method
loadConfiguration of VelocityServlet. Adjusted examples.
Revision Changes Path
1.4 +1 -1 jakarta-velocity-tools/struts/examples/struts/WEB-INF/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/struts/examples/struts/WEB-INF/web.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- web.xml 2 Apr 2002 16:46:29 -0000 1.3
+++ web.xml 4 Apr 2002 13:05:56 -0000 1.4
@@ -59,7 +59,7 @@
</init-param>
<init-param>
- <param-name>velocity.properties</param-name>
+ <param-name>properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
1.4 +11 -29 jakarta-velocity-tools/view/src/java/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java
Index: VelocityViewServlet.java
===================================================================
RCS file: /home/cvs/jakarta-velocity-tools/view/src/java/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- VelocityViewServlet.java 2 Apr 2002 16:46:31 -0000 1.3
+++ VelocityViewServlet.java 4 Apr 2002 13:05:56 -0000 1.4
@@ -107,7 +107,7 @@
* <dd>Path and name of the toolbox configuration file. The path must be
* relative to the web application root directory. If this parameter is
* not found, no toolbox is instantiated.</dd>
- * <dt>velocity.properties</dt>
+ * <dt>org.apache.velocity.properties</dt>
* <dd>Path and name of the Velocity configuration file. The path must be
* relative to the web application root directory. If this parameter
* is not present, Velocity is initialized with default settings.</dd>
@@ -116,7 +116,7 @@
* @author <a href="mailto:sidler@teamup.com">Gabe Sidler</a>
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
*
- * @version $Id: VelocityViewServlet.java,v 1.3 2002/04/02 16:46:31 sidler Exp $
+ * @version $Id: VelocityViewServlet.java,v 1.4 2002/04/04 13:05:56 sidler Exp $
*/
public class VelocityViewServlet extends VelocityServlet
@@ -220,35 +220,17 @@
protected void initVelocity( ServletConfig config )
throws ServletException
{
- // Read Velocity configuration
- ExtendedProperties velProps = new ExtendedProperties();
- String filename = config.getInitParameter(VELOCITY_PROPERTIES);
- if ( filename != null )
+ // Try reading Velocity configuration
+ try
{
- InputStream is = null;
- try
- {
- // ensure path start with '/'
- if ( !filename.startsWith("/") )
- {
- filename = "/" + filename;
- }
-
- is = getServletContext().getResourceAsStream(filename);
- if ( is != null)
- {
- getServletContext().log("Using configuration file '" + filename +"'");
- velProps.load(is);
- getServletContext().log("Configuration file sucessfully read.");
- }
- }
- catch( Exception e )
- {
- getServletContext().log("Problem reading Velocity configuration file '" + filename +"' : " + e );
- }
+ Properties p = super.loadConfiguration(config);
+ Velocity.setExtendedProperties(ExtendedProperties.convertProperties(p));
}
-
- Velocity.setExtendedProperties(velProps);
+ catch(Exception e)
+ {
+ getServletContext().log("Unable to read Velocity configuration file: " + e);
+ getServletContext().log("Using default Velocity configuration.");
+ }
// define servletlogger, which logs to the servlet engines log
ServletLogger sl = new ServletLogger( getServletContext() );
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-velocity-tools/view/src/java/org/apache/velocity/tools/view/servlet VelocityViewServlet.java
Posted by Daniel Rall <dl...@finemaltcoding.com>.
sidler@apache.org writes:
> sidler 02/04/04 05:05:57
>
> Modified: struts/examples/struts/WEB-INF web.xml
> view/src/java/org/apache/velocity/tools/view/servlet
> VelocityViewServlet.java
> Log:
> Modified VelocityViewServlet to load configuration using method
> loadConfiguration of VelocityServlet. Adjusted examples.
>
> Revision Changes Path
> 1.4 +1 -1 jakarta-velocity-tools/struts/examples/struts/WEB-INF/web.xml
>
> Index: web.xml
> ===================================================================
> RCS file: /home/cvs/jakarta-velocity-tools/struts/examples/struts/WEB-INF/web.xml,v
> retrieving revision 1.3
> retrieving revision 1.4
> diff -u -r1.3 -r1.4
> --- web.xml 2 Apr 2002 16:46:29 -0000 1.3
> +++ web.xml 4 Apr 2002 13:05:56 -0000 1.4
> @@ -59,7 +59,7 @@
> </init-param>
>
> <init-param>
> - <param-name>velocity.properties</param-name>
> + <param-name>properties</param-name>
> <param-value>/WEB-INF/velocity.properties</param-value>
> </init-param>
Note in CVS HEAD, this is property is named
org.apache.velocity.properties. However, no released version supports
that yet, and "properties" is supported in a deprecated fashion, so
this is probably the way to go under 1.4 is released.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>