Hi Jennie, I am fairly new to Struts 2 but you can certainly do action wildcard mappings with it, such as:
<action name="*" > <result>/{1}.jsp</result> </action> where foo.action would map to foo.jsp. However, my guess is that what you are asking for is a little bit more advanced (and judging by the "*.do" you are not using Struts 2). You might be better to look at using mod_rewrite on apache if you can. Alternatively you could create or use something like the URL rewriting servlet filter below. <http://tuckey.org/urlrewrite/> A very simple URL mapping servlet would do the trick and look something like the servlet below. I'm sure that other other here would be able to improve on this with some clever one line regular expression but at least it gives you an idea of how to do it: public class UrlMappingServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String path=req.getServletPath(); String queryString = req.getQueryString(); // cut off the extension and leading slash int end = path.lastIndexOf(".jsp"); path = path.substring(1, end); // split the path into components String[] pathcomponents = path.split("/"); // 0 -recipes // 1 - number String number = pathcomponents[1]; // 2 - recipe name String name = pathcomponents[2]; String destination = "/recipeDetails.jsp"?number=" + number + "&name=" + name + "&" + queryString; RequestDispatcher rd; rd = req.getRequestDispatcher(destination); rd.forward(req, resp); } } Of course, best practice states you should never go directly to a JSP url in a Struts app. You should always go via an action. HTH Mark On 9/28/07, Jennie Moeller <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to map a jsp page to an action. When any jsp gets loaded with > the recipe path on it I want it to go to an action. > > for example: > > This uri: recipes/4735/steak-with-barbecue-sauce.jsp > > I want it to hit my > > recipeDetails action > > My struts action looks like this: > > <action path="/recipes/**" > type="com.pub.actions.RecipeDetailsAction" > name="recipeDetailsForm" > scope="request" > validate="false"> > > <forward redirect="false" name="success" > path="/WEB-INF/jsp/recipeDetails.jsp" /> > </action> > > > > My web.xml looks like this: > > <servlet-mapping> > <servlet-name>action</servlet-name> > <url-pattern>/recipes/*/*.jsp</url-pattern> > </servlet-mapping> > > <servlet-mapping> > <servlet-name>action</servlet-name> > <url-pattern>*.do</url-pattern> > </servlet-mapping> > > > any ideas? > > thanks, > Jennie > > > This e-mail (and any attachments) is confidential and may contain > personal views which are not the views of the BBC unless specifically > stated. > If you have received it in error, please delete it from your system. > Do not use, copy or disclose the information in any way nor act in > reliance on it and notify the sender immediately. Please note that the > BBC monitors e-mails sent or received. > Further communication will signify your consent to this. > -- "Paradoxically, the more time saving abstractions you are using the more you actually have to know." - Simon Willison --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]