You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Michael Fortin <mi...@vendorpromotions.com> on 2005/08/04 16:44:29 UTC

replacement for jsp:forward

Hello all,

I've been trying to configure a site with velocity and spring and I'm 
having a little trouble with the welcome page.  With jsp I can just add 
an index.jsp with a jsp:forward in it to route to my servlet the will 
render my home page.  I really want to keep it a pure velocity site but 
there doesn't seem to be an equivalent to jsp:forward in velocity.  I've 
tried to set a servlet in my welcome file list in the web.xml but that 
didn't work, I just get a directory listing.  Is there a way to do this?


Thanks,
Michael


Re: replacement for jsp:forward

Posted by Michael Fortin <mi...@vendorpromotions.com>.
Thanks all for the replies. 
This is what I wound up using:
$request.getRequestDispatcher("/start.do").forward($request, $response)

I added only that line to a file named index.vm and put that in my 
welcome file list and it worked perfectly.

thanks again,
Michael


Charles Harvey III wrote:

> You CAN set a servlet in your welcome file list.  But you have to have
> a dummy file in the directory for it to work.
>
> I use Struts with Velocity, so I have the main page in a directory mapped
> as index.do in my struts-config.xml.  So, in said directory, I create an
> empty file called "index.do".  Either Apache or Tomcat will read through
> the directory, see the file, and attempt to serve it.  But then Tomcat
> will see that it should be serving a servlet instead and process it.
> Its a neat trick.
>
> Also, if you want to have "index.vm" pointing to a particular servlet,
> just have this and nothing else on the page:
>
> $response.sendRedirect( "/myServlet" )
>
>
> It is not exactly a forward, but it sends the request to the right place.
>
>
>
> Charlie
>
>
>
> Andrew Mason said the following on 8/4/2005 11:15 AM:
>
>> I think he meant an onLoad() in spring On Thu August 4 2005 4:04 pm, 
>> Michael Fortin wrote:
>>  
>>
>>> I could do a javascript redirect but that would assume that the client
>>> has javascript enabled.  A meta refresh would be an options too but I
>>> was hoping to avoid client side redirects, is there a way to do it
>>> server side?
>>>
>>> Thanks
>>> Michael
>>>
>>> Michael Oliver wrote:
>>>   
>>>
>>>> Just use a plain old index.html page and use onLoad to go to your 
>>>> velocity
>>>> entry point.
>>>>
>>>> Michael Oliver
>>>> CTO
>>>> Alarius Systems LLC
>>>> 6800 E. Lake Mead Blvd, #1096
>>>> Las Vegas, NV 89156
>>>> Phone:(702)643-7425
>>>> Fax:(702)974-0341
>>>> *Note new email changed from oliverm@matrix-media.com
>>>> -----Original Message-----
>>>> From: Michael Fortin [mailto:mikef@vendorpromotions.com]
>>>> Sent: Thursday, August 04, 2005 7:44 AM
>>>> To: Velocity Users List
>>>> Subject: replacement for jsp:forward
>>>>
>>>> Hello all,
>>>>
>>>> I've been trying to configure a site with velocity and spring and I'm
>>>> having a little trouble with the welcome page.  With jsp I can just 
>>>> add
>>>> an index.jsp with a jsp:forward in it to route to my servlet the will
>>>> render my home page.  I really want to keep it a pure velocity site 
>>>> but
>>>> there doesn't seem to be an equivalent to jsp:forward in velocity.  
>>>> I've
>>>> tried to set a servlet in my welcome file list in the web.xml but that
>>>> didn't work, I just get a directory listing.  Is there a way to do 
>>>> this?
>>>>
>>>>
>>>> Thanks,
>>>> Michael
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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: replacement for jsp:forward

Posted by Charles Harvey III <ch...@alloy.com>.
You CAN set a servlet in your welcome file list.  But you have to have
a dummy file in the directory for it to work.

I use Struts with Velocity, so I have the main page in a directory mapped
as index.do in my struts-config.xml.  So, in said directory, I create an
empty file called "index.do".  Either Apache or Tomcat will read through
the directory, see the file, and attempt to serve it.  But then Tomcat
will see that it should be serving a servlet instead and process it.
Its a neat trick.

Also, if you want to have "index.vm" pointing to a particular servlet,
just have this and nothing else on the page:

$response.sendRedirect( "/myServlet" )


It is not exactly a forward, but it sends the request to the right place.



Charlie



Andrew Mason said the following on 8/4/2005 11:15 AM:

>I think he meant an onLoad() in spring 
>On Thu August 4 2005 4:04 pm, Michael Fortin wrote:
>  
>
>>I could do a javascript redirect but that would assume that the client
>>has javascript enabled.  A meta refresh would be an options too but I
>>was hoping to avoid client side redirects, is there a way to do it
>>server side?
>>
>>Thanks
>>Michael
>>
>>Michael Oliver wrote:
>>    
>>
>>>Just use a plain old index.html page and use onLoad to go to your velocity
>>>entry point.
>>>
>>>Michael Oliver
>>>CTO
>>>Alarius Systems LLC
>>>6800 E. Lake Mead Blvd, #1096
>>>Las Vegas, NV 89156
>>>Phone:(702)643-7425
>>>Fax:(702)974-0341
>>>*Note new email changed from oliverm@matrix-media.com
>>>-----Original Message-----
>>>From: Michael Fortin [mailto:mikef@vendorpromotions.com]
>>>Sent: Thursday, August 04, 2005 7:44 AM
>>>To: Velocity Users List
>>>Subject: replacement for jsp:forward
>>>
>>>Hello all,
>>>
>>>I've been trying to configure a site with velocity and spring and I'm
>>>having a little trouble with the welcome page.  With jsp I can just add
>>>an index.jsp with a jsp:forward in it to route to my servlet the will
>>>render my home page.  I really want to keep it a pure velocity site but
>>>there doesn't seem to be an equivalent to jsp:forward in velocity.  I've
>>>tried to set a servlet in my welcome file list in the web.xml but that
>>>didn't work, I just get a directory listing.  Is there a way to do this?
>>>
>>>
>>>Thanks,
>>>Michael
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>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: replacement for jsp:forward

Posted by Andrew Mason <an...@assertis.co.uk>.
I think he meant an onLoad() in spring 
On Thu August 4 2005 4:04 pm, Michael Fortin wrote:
> I could do a javascript redirect but that would assume that the client
> has javascript enabled.  A meta refresh would be an options too but I
> was hoping to avoid client side redirects, is there a way to do it
> server side?
>
> Thanks
> Michael
>
> Michael Oliver wrote:
> >Just use a plain old index.html page and use onLoad to go to your velocity
> >entry point.
> >
> >Michael Oliver
> >CTO
> >Alarius Systems LLC
> >6800 E. Lake Mead Blvd, #1096
> >Las Vegas, NV 89156
> >Phone:(702)643-7425
> >Fax:(702)974-0341
> >*Note new email changed from oliverm@matrix-media.com
> >-----Original Message-----
> >From: Michael Fortin [mailto:mikef@vendorpromotions.com]
> >Sent: Thursday, August 04, 2005 7:44 AM
> >To: Velocity Users List
> >Subject: replacement for jsp:forward
> >
> >Hello all,
> >
> >I've been trying to configure a site with velocity and spring and I'm
> >having a little trouble with the welcome page.  With jsp I can just add
> >an index.jsp with a jsp:forward in it to route to my servlet the will
> >render my home page.  I really want to keep it a pure velocity site but
> >there doesn't seem to be an equivalent to jsp:forward in velocity.  I've
> >tried to set a servlet in my welcome file list in the web.xml but that
> >didn't work, I just get a directory listing.  Is there a way to do this?
> >
> >
> >Thanks,
> >Michael
> >
> >
> >
> >---------------------------------------------------------------------
> >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: replacement for jsp:forward

Posted by Robert Koberg <ro...@koberg.com>.
Michael Fortin wrote:
> I could do a javascript redirect but that would assume that the client 
> has javascript enabled.  A meta refresh would be an options too but I 
> was hoping to avoid client side redirects, is there a way to do it 
> server side?


A javax.servlet.Filter mapped to what you want to redirect from?

-Rob



> 
> Thanks
> Michael
> 

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


Re: replacement for jsp:forward

Posted by Michael Fortin <mi...@vendorpromotions.com>.
I could do a javascript redirect but that would assume that the client 
has javascript enabled.  A meta refresh would be an options too but I 
was hoping to avoid client side redirects, is there a way to do it 
server side?

Thanks
Michael


Michael Oliver wrote:

>Just use a plain old index.html page and use onLoad to go to your velocity
>entry point.
>
>Michael Oliver
>CTO
>Alarius Systems LLC
>6800 E. Lake Mead Blvd, #1096
>Las Vegas, NV 89156
>Phone:(702)643-7425
>Fax:(702)974-0341
>*Note new email changed from oliverm@matrix-media.com
>-----Original Message-----
>From: Michael Fortin [mailto:mikef@vendorpromotions.com] 
>Sent: Thursday, August 04, 2005 7:44 AM
>To: Velocity Users List
>Subject: replacement for jsp:forward
>
>Hello all,
>
>I've been trying to configure a site with velocity and spring and I'm 
>having a little trouble with the welcome page.  With jsp I can just add 
>an index.jsp with a jsp:forward in it to route to my servlet the will 
>render my home page.  I really want to keep it a pure velocity site but 
>there doesn't seem to be an equivalent to jsp:forward in velocity.  I've 
>tried to set a servlet in my welcome file list in the web.xml but that 
>didn't work, I just get a directory listing.  Is there a way to do this?
>
>
>Thanks,
>Michael
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>  
>


RE: ClasspathResourceLoader no worky

Posted by Michael Oliver <ol...@alariussystems.com>.
I know I tried this before, but probably before I realized I had mixed the
Velocity.mergeTemplate() with the ve.mergeTemplate()

But this works

ve.mergeTemplate("com/alarius/datasource/Hibernate_cfg_xml.vm",
Velocity.ENCODING_DEFAULT,context, sw);


Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com
-----Original Message-----
From: Michael Oliver [mailto:ollie@alariussystems.com] 
Sent: Friday, August 05, 2005 5:50 AM
To: 'Velocity Users List'
Subject: RE: ClasspathResourceLoader no worky

Well no, since I am using the ClasspathResourceLoader I am not overriding
the file.resource.loader.path.

Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com
-----Original Message-----
From: Jean Francois Chamard [mailto:jfchamard@interstructure.ca] 
Sent: Thursday, August 04, 2005 3:12 PM
To: Velocity Users List
Subject: Re: ClasspathResourceLoader no worky

Did you try to set the

"file.resource.loader.path"
velocity property?

By default, it checks in .

>From the dev guide:
*Default Configuration : * As the name says, there is nothing
you have to do or configure to get the default configuration.  This
configuration
uses the FileResourceLoader with the current directory as the default
resource
path, and caching is off.

You can set more than one directory with this property.

Jeff


Michael Oliver wrote:

>Ok found part of the solution
>
>I changed 
>
>ve.init();
>sw = new StringWriter();
>Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
>
>To 
>
>ve.init();
>sw = new StringWriter();
>ve.mergeTemplate("Hibernate_cfg_xml.vm",
>
>but the only copy of the template it is finding is the one stored at the
>root of the jar and not the one down in the package.
>
>I have /Hibernate_cfg_xml.vm and
>/com/alarius/datasource/Hibernate_cfg_xml.vm 
>
>and I have tried 
>
>ve.mergeTemplate("Hibernate_cfg_xml.vm",
>ve.mergeTemplate("/com/alarius/datasource/Hibernate_cfg_xml.vm",
>
>and even
>
>ve.mergeTemplate("com.alarius.datasource.Hibernate_cfg_xml.vm",
>
>
>Michael Oliver
>CTO
>Alarius Systems LLC
>6800 E. Lake Mead Blvd, #1096
>Las Vegas, NV 89156
>Phone:(702)643-7425
>Fax:(702)974-0341
>*Note new email changed from oliverm@matrix-media.com
>
>-----Original Message-----
>From: Michael Oliver [mailto:ollie@alariussystems.com] 
>Sent: Thursday, August 04, 2005 1:49 PM
>To: 'Velocity Users List'
>Subject: ClasspathResourceLoader no worky
>
>
>I have a JUnit test that I can't seem to get working tieh
>ClasspathResourceLoader.
>
>VelocityEngine ve = new VelocityEngine();
>
>ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
>ve.setProperty(Velocity.RESOURCE_LOADER, "class");
>ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.r
e
>source.loader.ClasspathResourceLoader");
>		
>VelocityContext context = new VelocityContext();
>context.put("username", new String("root"));
>context.put("password", new String("letmein"));
>		
>StringWriter sw = null;
>try {
>	ve.init();
>	sw = new StringWriter();
>	Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
>Velocity.ENCODING_DEFAULT,context, sw);
>} catch (ResourceNotFoundException e) {
>	e.printStackTrace();
>}
>
>I am running Eclipse 3.0 with JUnit 3.8 and I have the debug runtime
>classpath including a jar with the Hibernate_cfg_xml.vm file in several
>locations, but whenever I run this test it throws the
>ResourceNotFoundException.
>
>I have the template located in the jar at the root and in a couple of
>package directories.
>
>I cannot get it to find it.
>
>Is this a problem with the JUnit class loader?
>
>I looked in the debugger and the resourceLoader IS the
>ClasspathResourceLoader so I know that part is at least working.
>
>
>
>
>---------------------------------------------------------------------
>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



---------------------------------------------------------------------
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: ClasspathResourceLoader no worky

Posted by Michael Oliver <ol...@alariussystems.com>.
Well no, since I am using the ClasspathResourceLoader I am not overriding
the file.resource.loader.path.

Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com
-----Original Message-----
From: Jean Francois Chamard [mailto:jfchamard@interstructure.ca] 
Sent: Thursday, August 04, 2005 3:12 PM
To: Velocity Users List
Subject: Re: ClasspathResourceLoader no worky

Did you try to set the

"file.resource.loader.path"
velocity property?

By default, it checks in .

>From the dev guide:
*Default Configuration : * As the name says, there is nothing
you have to do or configure to get the default configuration.  This
configuration
uses the FileResourceLoader with the current directory as the default
resource
path, and caching is off.

You can set more than one directory with this property.

Jeff


Michael Oliver wrote:

>Ok found part of the solution
>
>I changed 
>
>ve.init();
>sw = new StringWriter();
>Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
>
>To 
>
>ve.init();
>sw = new StringWriter();
>ve.mergeTemplate("Hibernate_cfg_xml.vm",
>
>but the only copy of the template it is finding is the one stored at the
>root of the jar and not the one down in the package.
>
>I have /Hibernate_cfg_xml.vm and
>/com/alarius/datasource/Hibernate_cfg_xml.vm 
>
>and I have tried 
>
>ve.mergeTemplate("Hibernate_cfg_xml.vm",
>ve.mergeTemplate("/com/alarius/datasource/Hibernate_cfg_xml.vm",
>
>and even
>
>ve.mergeTemplate("com.alarius.datasource.Hibernate_cfg_xml.vm",
>
>
>Michael Oliver
>CTO
>Alarius Systems LLC
>6800 E. Lake Mead Blvd, #1096
>Las Vegas, NV 89156
>Phone:(702)643-7425
>Fax:(702)974-0341
>*Note new email changed from oliverm@matrix-media.com
>
>-----Original Message-----
>From: Michael Oliver [mailto:ollie@alariussystems.com] 
>Sent: Thursday, August 04, 2005 1:49 PM
>To: 'Velocity Users List'
>Subject: ClasspathResourceLoader no worky
>
>
>I have a JUnit test that I can't seem to get working tieh
>ClasspathResourceLoader.
>
>VelocityEngine ve = new VelocityEngine();
>
>ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
>ve.setProperty(Velocity.RESOURCE_LOADER, "class");
>ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.r
e
>source.loader.ClasspathResourceLoader");
>		
>VelocityContext context = new VelocityContext();
>context.put("username", new String("root"));
>context.put("password", new String("letmein"));
>		
>StringWriter sw = null;
>try {
>	ve.init();
>	sw = new StringWriter();
>	Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
>Velocity.ENCODING_DEFAULT,context, sw);
>} catch (ResourceNotFoundException e) {
>	e.printStackTrace();
>}
>
>I am running Eclipse 3.0 with JUnit 3.8 and I have the debug runtime
>classpath including a jar with the Hibernate_cfg_xml.vm file in several
>locations, but whenever I run this test it throws the
>ResourceNotFoundException.
>
>I have the template located in the jar at the root and in a couple of
>package directories.
>
>I cannot get it to find it.
>
>Is this a problem with the JUnit class loader?
>
>I looked in the debugger and the resourceLoader IS the
>ClasspathResourceLoader so I know that part is at least working.
>
>
>
>
>---------------------------------------------------------------------
>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



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


Re: ClasspathResourceLoader no worky

Posted by Jean Francois Chamard <jf...@interstructure.ca>.
Did you try to set the

"file.resource.loader.path"
velocity property?

By default, it checks in .

>From the dev guide:
*Default Configuration : * As the name says, there is nothing
you have to do or configure to get the default configuration.  This configuration
uses the FileResourceLoader with the current directory as the default resource
path, and caching is off.

You can set more than one directory with this property.

Jeff


Michael Oliver wrote:

>Ok found part of the solution
>
>I changed 
>
>ve.init();
>sw = new StringWriter();
>Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
>
>To 
>
>ve.init();
>sw = new StringWriter();
>ve.mergeTemplate("Hibernate_cfg_xml.vm",
>
>but the only copy of the template it is finding is the one stored at the
>root of the jar and not the one down in the package.
>
>I have /Hibernate_cfg_xml.vm and
>/com/alarius/datasource/Hibernate_cfg_xml.vm 
>
>and I have tried 
>
>ve.mergeTemplate("Hibernate_cfg_xml.vm",
>ve.mergeTemplate("/com/alarius/datasource/Hibernate_cfg_xml.vm",
>
>and even
>
>ve.mergeTemplate("com.alarius.datasource.Hibernate_cfg_xml.vm",
>
>
>Michael Oliver
>CTO
>Alarius Systems LLC
>6800 E. Lake Mead Blvd, #1096
>Las Vegas, NV 89156
>Phone:(702)643-7425
>Fax:(702)974-0341
>*Note new email changed from oliverm@matrix-media.com
>
>-----Original Message-----
>From: Michael Oliver [mailto:ollie@alariussystems.com] 
>Sent: Thursday, August 04, 2005 1:49 PM
>To: 'Velocity Users List'
>Subject: ClasspathResourceLoader no worky
>
>
>I have a JUnit test that I can't seem to get working tieh
>ClasspathResourceLoader.
>
>VelocityEngine ve = new VelocityEngine();
>
>ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
>ve.setProperty(Velocity.RESOURCE_LOADER, "class");
>ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.re
>source.loader.ClasspathResourceLoader");
>		
>VelocityContext context = new VelocityContext();
>context.put("username", new String("root"));
>context.put("password", new String("letmein"));
>		
>StringWriter sw = null;
>try {
>	ve.init();
>	sw = new StringWriter();
>	Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
>Velocity.ENCODING_DEFAULT,context, sw);
>} catch (ResourceNotFoundException e) {
>	e.printStackTrace();
>}
>
>I am running Eclipse 3.0 with JUnit 3.8 and I have the debug runtime
>classpath including a jar with the Hibernate_cfg_xml.vm file in several
>locations, but whenever I run this test it throws the
>ResourceNotFoundException.
>
>I have the template located in the jar at the root and in a couple of
>package directories.
>
>I cannot get it to find it.
>
>Is this a problem with the JUnit class loader?
>
>I looked in the debugger and the resourceLoader IS the
>ClasspathResourceLoader so I know that part is at least working.
>
>
>
>
>---------------------------------------------------------------------
>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: ClasspathResourceLoader no worky

Posted by Michael Oliver <ol...@alariussystems.com>.
Ok found part of the solution

I changed 

ve.init();
sw = new StringWriter();
Velocity.mergeTemplate("Hibernate_cfg_xml.vm",

To 

ve.init();
sw = new StringWriter();
ve.mergeTemplate("Hibernate_cfg_xml.vm",

but the only copy of the template it is finding is the one stored at the
root of the jar and not the one down in the package.

I have /Hibernate_cfg_xml.vm and
/com/alarius/datasource/Hibernate_cfg_xml.vm 

and I have tried 

ve.mergeTemplate("Hibernate_cfg_xml.vm",
ve.mergeTemplate("/com/alarius/datasource/Hibernate_cfg_xml.vm",

and even

ve.mergeTemplate("com.alarius.datasource.Hibernate_cfg_xml.vm",


Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com

-----Original Message-----
From: Michael Oliver [mailto:ollie@alariussystems.com] 
Sent: Thursday, August 04, 2005 1:49 PM
To: 'Velocity Users List'
Subject: ClasspathResourceLoader no worky


I have a JUnit test that I can't seem to get working tieh
ClasspathResourceLoader.

VelocityEngine ve = new VelocityEngine();

ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
ve.setProperty(Velocity.RESOURCE_LOADER, "class");
ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.re
source.loader.ClasspathResourceLoader");
		
VelocityContext context = new VelocityContext();
context.put("username", new String("root"));
context.put("password", new String("letmein"));
		
StringWriter sw = null;
try {
	ve.init();
	sw = new StringWriter();
	Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
Velocity.ENCODING_DEFAULT,context, sw);
} catch (ResourceNotFoundException e) {
	e.printStackTrace();
}

I am running Eclipse 3.0 with JUnit 3.8 and I have the debug runtime
classpath including a jar with the Hibernate_cfg_xml.vm file in several
locations, but whenever I run this test it throws the
ResourceNotFoundException.

I have the template located in the jar at the root and in a couple of
package directories.

I cannot get it to find it.

Is this a problem with the JUnit class loader?

I looked in the debugger and the resourceLoader IS the
ClasspathResourceLoader so I know that part is at least working.




---------------------------------------------------------------------
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


ClasspathResourceLoader no worky

Posted by Michael Oliver <ol...@alariussystems.com>.
I have a JUnit test that I can't seem to get working tieh
ClasspathResourceLoader.

VelocityEngine ve = new VelocityEngine();

ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
ve.setProperty(Velocity.RESOURCE_LOADER, "class");
ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.re
source.loader.ClasspathResourceLoader");
		
VelocityContext context = new VelocityContext();
context.put("username", new String("root"));
context.put("password", new String("letmein"));
		
StringWriter sw = null;
try {
	ve.init();
	sw = new StringWriter();
	Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
Velocity.ENCODING_DEFAULT,context, sw);
} catch (ResourceNotFoundException e) {
	e.printStackTrace();
}

I am running Eclipse 3.0 with JUnit 3.8 and I have the debug runtime
classpath including a jar with the Hibernate_cfg_xml.vm file in several
locations, but whenever I run this test it throws the
ResourceNotFoundException.

I have the template located in the jar at the root and in a couple of
package directories.

I cannot get it to find it.

Is this a problem with the JUnit class loader?

I looked in the debugger and the resourceLoader IS the
ClasspathResourceLoader so I know that part is at least working.




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


RE: replacement for jsp:forward

Posted by Michael Oliver <ol...@alariussystems.com>.
Just use a plain old index.html page and use onLoad to go to your velocity
entry point.

Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com
-----Original Message-----
From: Michael Fortin [mailto:mikef@vendorpromotions.com] 
Sent: Thursday, August 04, 2005 7:44 AM
To: Velocity Users List
Subject: replacement for jsp:forward

Hello all,

I've been trying to configure a site with velocity and spring and I'm 
having a little trouble with the welcome page.  With jsp I can just add 
an index.jsp with a jsp:forward in it to route to my servlet the will 
render my home page.  I really want to keep it a pure velocity site but 
there doesn't seem to be an equivalent to jsp:forward in velocity.  I've 
tried to set a servlet in my welcome file list in the web.xml but that 
didn't work, I just get a directory listing.  Is there a way to do this?


Thanks,
Michael



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