my dog learned polymorphism
The moose likes Other Open Source Projects and the fly likes Velocity servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Velocity servlet" Watch "Velocity servlet" New topic

Velocity servlet

shubhra mathur

Joined: Mar 28, 2007
Posts: 2
Hi, I have created one velocity servlet and velocity template which is called by servlet. file is created where i am giving the path of template .
When i am calling the sevlet in web browser it is showing servlet not found exception though i have given the path of servlet in web.xml.
Please help me.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Welcome to JavaRanch.

Which URL are you using to access the servlet, and what do the servlet declaration and mapping from web.xml look like? TellTheDetails
shubhra mathur

Joined: Mar 28, 2007
Posts: 2
In url i am giving localhost:8080/servletname.
My web.xml--
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"



my Servlet---
import org.apache.velocity.Template;
import org.apache.velocity.servlet.VelocityServlet;
import org.apache.velocity.context.Context;
import javax.servlet.http.*;

public class Hello extends VelocityServlet {

private static final long serialVersionUID = 1L;

public Template handleRequest( HttpServletRequest request,
HttpServletResponse response,
Context context ) {

Template template = null;

try {
context.put("name", "Velocity Test");
template = Velocity.getTemplate("/hello.vm");
} catch( Exception e ) {
System.err.println("Exception caught: " + e.getMessage());

return template;
I agree. Here's the link:
subject: Velocity servlet
It's not a secret anymore!