| ||||||||||||||
Resin 3.1 Documentation Examples Changes Quercus Database Amber EJB SOA/ESB IoC JMS Servlet JMX Hessian Security Hello, World IoC |
Resin allows servlets to be configured with bean-style setters. With Resin, servlets can use Java Bean-style configuration. A "Java Bean"
is just a Java class that follows a simple set of rules. Each configuration
parameter Files in this tutorial
HelloServletThe following package test; import java.io.*; import javax.servlet.http.*; import javax.servlet.*; public class HelloServlet extends HttpServlet { private String _greeting = "Default"; public void setGreeting(String greeting) { _greeting = greeting; } public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { PrintWriter out = res.getWriter(); out.println(_greeting); out.close(); } } ConfigurationThe servlet configuration sets the property
inside an init/servlet tag. After Resin instantiates the servlet object,
it looks at the configuration file for any <init> section. Resin then
calls a Resin will perform any type conversion necessary, so you can use
integers and doubles as well as strings. After Resin calls the When Resin initializes the servlet, it will make the following calls:
<web-app xmlns="http://caucho.com/ns/resin"> <servlet servlet-name="hello" servlet-class="test.HelloServlet"> <init> <greeting>Hello, World!</greeting> </init> </servlet> <servlet-mapping url-pattern="/hello" servlet-name="hello"/> </web-app>
|