Question { IBM, 22591 }
How can I make own ActionServlet? with example
Answer
You can make your own ActionServlet by extending
RequestProcessor class and overriding its methods. The
example is given below....
package com.visualbuilder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.RequestProcessor;
public class CustomRequestProcessor extends
RequestProcessor {
public boolean processPreprocess(HttpServletRequest
request, HttpServletResponse response) {
System.out.println("Called the preprocess method before
processing the request");
return super.processPreprocess(request,response);
}
}
The following is web.xml file u should change it accoringly
version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-
app_2_4.xsd">
action
name>
class>com.visualbuilder.CustomActionServlet
class> config
name> /WEB-INF/struts-config.xml
value> 2
startup>
name>action *.do
pattern>
file>index.jsp