logo       

Re: Newbie - Keep getting ResourceNotFoundException: msg#00187

jakarta.velocity.user

Subject: Re: Newbie - Keep getting ResourceNotFoundException

You servlet is having a problem finding the template. If you search the
archives you find a bunch of articles that explain how to fix this.
Instead I think it is easier to get started with Velocity in Servlets by using
VelocityServlet and extending it. This does most of the initalization stuff.

HTH,

Jeff

Søren Neigaard wrote:

> I'm trying to make a simple HelloWorld example, and I'm doing this
> from inside the doGet method in a servlet:
>
> ------------------
> Velocity.init();
> VelocityContext context = new VelocityContext();
> context.put("name", new String("Velocity Test"));
> Template template = null;
> try {
> template = Velocity.getTemplate("mytemplate.vm");
> template.merge(context,response.getWriter());
> }
> catch(Exception e){
> e.printStackTrace();
> }
> ------------------
>
> Where does it look for the template? Can it be on the file system, or
> must it be accessible via HTTP? I have now tried to pint it directly
> to the path where the file is, and i get this error:
>
> ------------------
> org.apache.velocity.exception.ResourceNotFoundException: Unable to
> find resource
> '/C:/jakarta-tomcat-4.1.10-LE-jdk14/webapps/yaf/mytemplate.vm'
> ------------------
>
> And the file is there!? Please advice, what is my (simple) problem?
>
> --
> Med venlig hilsen/Best regards,
> Søren Neigaard mailto:neigaard@xxxxxxxx
> --
> "First we thought the PC was a calculator. Then we found out how to turn
> numbers into letters with ASCII ? and we thought it was a typewriter. Then we
> discovered graphics, and we thought it was a television. With the World Wide
> Web, we've realized it's a brochure."
>
> --
> To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx>
> For additional commands, e-mail:
> <mailto:velocity-user-help@xxxxxxxxxxxxxxxxxx>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise