Multiple RequestProcessor in one Struts Application
1 posts in topic
Flat View  Flat View

Posted By:   rajdeep_paul
Posted On:   Sunday, December 5, 2004 10:53 PM

Is it possible to use multiple *RequestProcessor* in one application.

I am using StrutsWorkflow Extension in for one part of my application, which has its own RequestProcessor class and I am mentioning it in the Controller tag of struts-cofig.xml.

Now for the rest of my application I want to write my own RequestProcessor.

How can we tell struts about two RequestProcessors so that the ActionServlet can distinguish between the requests and forward it to the correct RequestProcessor?

Re: Multiple RequestProcessor in one Struts Application

Posted By:   Anonymous  
Posted On:   Sunday, December 26, 2004 11:41 AM

u r not supposed to use two or 3 req processor sin struts-congig.xml ..

but u can trace from which action the req comes .. depending on that do something forwarding or retruning false..

see the below snippet

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.RequestProcessor;

* @author administrator
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments

public class CustomRequestProcessor extends
RequestProcessor {

protected boolean processPreprocess(HttpServletRequest request,HttpServletResponse response) {

HttpSession session =
//If user is trying to access login page then dont check

if( request.getServletPath().equals
("/loginInput.do") || request.getServletPath().equals("/login.do") )

return true;

//Check if userName attribute is there is session. If yes then that means user has allready loggedIn

if( session != null && session.getAttribute("userName") != null)

return true;

//If no redirect user to login Page


}catch(Exception ex){
return false;


protected void processContent(HttpServletRequest
request,HttpServletResponse response) {
//Check if user is requesting
ContactImageAction if yes then set image/gif as content type

if( request.getServletPath().equals("/contactimage.do")){


super.processContent(request, response);

grgowtham_cse@yahoo.com is my id if u want further clarification
About | Sitemap | Contact