I used something like this once.

First I extended RequestProcessor. I picked the processActionPerform method because it's one of the last ones to be invoked by the controller, and various attributes tend to get removed/added as the controller moves through the request processing chain. Sometimes it's helpful to override two and compare. Don't forget you have access to the source, too, but I think this is quicker. Don't forget to invoke super when you override these methods. Also you could do this with a filter I suppose. Also you could do it in a scriplet in a JSP.

public class MyRequestProcessor extends org.apache.struts.action.RequestProcessor {

public ActionForward processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) {
//do what would be done by default
ActionForward forward = super.processActionPerform(request, response, action, form, mapping);
//add debugging code
Enumeration requestAttributeNames = request.getAttributeNames();
while (requestAttributeNames.hasMoreElements()) {
String key = (String) requestAttributeNames.nextElement();
String value = request.getAttribute(key).toString();
System.out.println("request attribute: key = " + key + "; value = " + value);
}
HttpSession session = request.getSession();
Enumeration sessionAttributeNames = session.getAttributeNames();
while (sessionAttributeNames.hasMoreElements()) {
String key = (String) sessionAttributeNames.nextElement();
String value = session.getAttribute(key).toString();
System.out.println("session attribute: key = " + key + "; value = " + value);
}
ServletContext app = servlet.getServletContext();
Enumeration appAttributeNames = app.getAttributeNames();
while (appAttributeNames.hasMoreElements()) {
String key = (String) appAttributeNames.nextElement();
String value = app.getAttribute(key).toString();
System.out.println("app attribute: key = " + key + "; value = " + value);
}
return forward;
}


}

Now you can see what's available to your Action (and to your JSP after the Action handles the request) as far as attributes go.

You can just turn this debugging on and off in struts-config.xml by telling Struts whether to use the custom request processor in the "controller" element:

<controller processorClass="MyRequestProcessor"/>

Commenting this out causes the default processor to be used again.


Hope that helps,

Erik




Ben Taylor wrote:

I must admit I'm a little unsure of how to do that within the JSP. I'm tempted to use request.getRequestURI() from within the
StrutsAction and place that value into the session / request under my
own variable name.... Obviously if a value already exists that is in
scope I'd much prefer to use that.


Cheers.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to