File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Velocity servlet" Watch "Velocity servlet" New topic
Author

Velocity servlet

shubhra mathur
Greenhorn

Joined: Mar 28, 2007
Posts: 2
Hi, I have created one velocity servlet and velocity template which is called by servlet. Velocity.properties 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
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
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
Greenhorn

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"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>Hello</servlet-class>
<init-param>
<param-name>properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>

</web-app>
my Servlet---
import org.apache.velocity.Template;
import org.apache.velocity.servlet.VelocityServlet;
import org.apache.velocity.app.Velocity;
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: http://aspose.com/file-tools
 
subject: Velocity servlet