This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Velocity servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Products » Other Open Source Projects
Reply 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: 35443
    
    9
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


Android appsImageJ pluginsJava web charts
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
 
Similar Threads
Ajax application response time
xml, servlet, velocity architecture
What should be the path of .vm in servlet ( Apache Velocity) ( Where is .vm file placed)
Finding a File outside Workspace in Eclipse IDE
Does velocity engine supports I18N ?