A solution in Struts v1.2.4 is at hand, too bad it's not some quick method call like getPattern(). If you can figure out what I did, you can use it. :) Seriously, I obtained a raw list of Action Mappings (unprocessed paths, as in Struts config files), then I used a Struts util class WildCardHelper to match the patterns, and viola!
WARNING: Since my webapp has only one struts config file, I haven't tested this code with Modules. If it doesn't work and you have modules, you'll have to figure out how to check the ActionConfig's in each module's ModuleConfig (and how to get each modules ModuleConfig). WARNING #2: Use the below code at your own risk. WARNING #3: If I find you using my package name, I'm going to beat you with my copy of Struts In Action! (Am I joking?) package com.friedsoftware.struts; import java.util.HashMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.config.ActionConfig; import org.apache.struts.util.WildcardHelper; /** * @author David * @struts.action path = "/hello" validate = "false" name = "DavidForm" * @struts.action path = "/hi_there" validate = "false" * @struts.action path = "/testpatt/**" validate = "false" * @struts.action-forward name = "success" path = "/index.jsp" */ public class ActionExample extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int counter = 0, pattern[]; boolean result; ActionConfig[] aConfig = mapping.getModuleConfig().findActionConfigs(); HashMap hm = new HashMap(); String myPath = request.getPathInfo(); WildcardHelper wh = new WildcardHelper(); while (counter < aConfig.length) { pattern = wh.compilePattern(aConfig[counter].getPath()); // ******** HERE IT COMES!!!! ********** result = wh.match(hm, myPath, pattern); if (result) { // ****** Okay, now what do YOU want // to do here? Now that you've found // the regular pattern, or wildcard // expression? break; } counter++; } return (mapping.findForward("success")); }; } // End of Class Regards, David -----Original Message----- From: news [mailto:[EMAIL PROTECTED] Behalf Of Alan Pocklington Sent: Friday, October 15, 2004 10:55 AM To: [EMAIL PROTECTED] Subject: Re: [REPOST] Get Raw Action Path. Thanks for the pointer. I've been looking through the RequestProcessor source without any luck so far. Maybe I'll stumble across it soon. Erik Weber <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > I don't know the specific answer to your question, but I learned a lot > by writing a method that prints out the key and value for every > attribute in every scope, and calling that method at various points > along the RequestProcessor timeline (by overriding various methods of > RequestProcessor). RequestProcessor invokes a dozen or so methods on > itself for every request, and during that time many attributes are set > and/or removed from various scopes. > > I do recall that the controller Servlet mapping was available. Not > sure about specific Action mappings. > > Erik > > > > Alan Pocklington wrote: > >>I have an Action defined as: >> >> <action >> path="/myaction/**" >> type="...MyAction"/> >> >>Within the Action class itself I want to get at the path attribute as >>defined in the config file, i.e. >>/myaction/**. >> >>I can get the requested path, for example /myaction/somepath/xxx.do >>via actionMapping.getPath() but not the original path to which the >>action was mapped. Is there any way I can get at this? >> >>Thanks in advance. >> >> >>--------------------------------------------------------------------- >>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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]