Re: Struts question: Calling Action by URL

Discussion in 'Java' started by Joerg Gippert, Jul 3, 2003.

  1. "Joerg Gippert" <> schrieb im Newsbeitrag
    news:-ip.de...
    > Hello everyone!


    Ok, found the mistake. Just replying to myselfe, in case someone else runs
    in to the same mistake and does a Google search on that topic. Here´s what I
    did wrong:

    Using the following line in the global-fowards section, will cause Struts to
    look for an action whose path is 'ShowItemDetAction':

    <forward name="showdetails" contextRelative="true"
    path="/ShowItemDetAction.do" redirect="true"/>

    Thus, I added an action mapping that looks like this:

    <action path="/ShowItemDetAction"
    type="com.mycompany.struts.action.ShowItemDetAction"></action>

    The JSP still looks like this:
    <html:link forward="showdetails" paramId="iid" paramName="ITEMS"
    paramProperty="itemid">
    <bean:write name="ITEMS" property="itemid" />
    <bean:write name="ITEMS" property="name" />
    </html:link>

    which produces an output of links like: http://127.0.0.1/myapp/test.do?iid=6

    Clicking on that link envokes the actionservlet 'ShowItemDetAction'. The
    parameter 'iid' can be accessed by something like:

    String iids[] = request.getParameterValues("iid");
    String id = iids[0]; //id would be '6' according to link stated above

    Make sure to catch an empty array.

    Regards,
    Joerg


    > I´m trying to call an actionsverlet by an URL in order to pass a parameter
    > to the actionservlet. I have an jsp, that list a couple of items. By
    > clicking on a link next to the item, another JSP should be opened with the
    > item´s details. The item list JSP looks like that:
    >
    > <logic:iterate id="ITEMS" name="ITEM" property="list">
    > <html:link forward="showdetails" paramId="iid" paramName="ITEMS"
    > paramProperty="itemid">
    > <bean:write name="ITEMS" property="itemid" />
    > <bean:write name="ITEMS" property="name" />
    > </html:link>
    > </logic:iterate>
    >
    > This works fine. The links produced by this JSP look like this:
    > http://127.0.0.1/MyApp/ShowItemDetAction.do?iid=6
    > When I click on such a link, I get the following error:
    >
    > HTTP Status 400
    > type Status report
    > message Invalid path /ShowItemDetAction was requested
    > description The request sent by the client was syntactically incorrect
    > (Invalid path /ShowItemDetAction was requested).
    >
    > In my Struts-config file, I wrote this:
    > <global-forwards>
    > <forward name="showdetails" contextRelative="true"
    > path="/ShowItemDetAction.do" redirect="true"/>
    > </global-forwards>
    >
    > In the same config file, there are also some action mappings. If I call
    > those actionservlets by an url (eg. "/addItem.do") it works without any
    > problem. The classfiles are all in the right place (ShowItemDetAction

    *does*
    > exist).
    >
    > I had a look at the apache struts website´s userguide and I can´t see what
    > I´m doing wrong. Anyone here who has a hint for me? Any help is greatly
    > appreciated!
    >
    > Thanks in advance,
    > regards
    > Joerg
    >
    >
     
    Joerg Gippert, Jul 3, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Bloggs
    Replies:
    1
    Views:
    951
    Sudsy
    Aug 3, 2003
  2. rjweytens
    Replies:
    6
    Views:
    16,302
    rjweytens
    Jun 25, 2004
  3. runescience

    Struts mapping action to action???

    runescience, Feb 6, 2006, in forum: Java
    Replies:
    3
    Views:
    1,926
    runescience
    Feb 7, 2006
  4. vyshu
    Replies:
    1
    Views:
    2,666
    Richard Senior
    Apr 27, 2007
  5. John
    Replies:
    0
    Views:
    983
Loading...

Share This Page