documentation examples changes amber (jpa) ejb database ioc jmx jsf messaging quercus remoting servlet security hello, world comet ioc | dependency-injection servlet configuration
Resin allows servlets to be configured using dependency injection. 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
The 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(); } } The 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>
|