Am I crazy or is Jennie using Struts 1.x and Mark just proposed a
solution for 2.x?

Jennie, your web.xml servler-mapping is overriding each other, you're
first saying you want /*/*.jsp sent to action but then you're saying
you want *.do's sent to action? I'm not too sure if that's valid.
Have you tried just using *.jsp like the following and see how far you
get?

<servlet-mapping>
       <servlet-name>action</servlet-name>
       <url-pattern>*.jsp</url-pattern>
   </servlet-mapping>

Zarar


On 9/28/07, Jennie Moeller <[EMAIL PROTECTED]> wrote:
> Thank much Mark,
>
> I talked with a colleague and we're going to give the urlrewrite a try.
> Thanks!
> -----Original Message-----
> From: Mark McLaren [mailto:[EMAIL PROTECTED]
> Sent: 28 September 2007 12:02
> To: Struts Users Mailing List
> Subject: Re: Mapping a jsp to an action
>
> 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]
>
>
>
> 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.
>
> ---------------------------------------------------------------------
> 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