struts html:form resolving action with double slashes

Discussion in 'Java' started by ramakrishna, May 8, 2007.

  1. ramakrishna

    ramakrishna Guest

    Dear all,

    I have a problem in html:form form tag.

    Iam using following html code.


    <html:form action="/addUser.do">
    </html>

    while resolving the aciton it is giving the following result.

    <form method="post" name="userForm" action="//addUser.do">
    </form>

    Iam getting "//addUser.do" double slashes in action element.

    Could you please send me the solution for this.

    Please send me reply.

    Thanks In Advance.

    Please find the struts-config.xml entry


    - <form-beans>
    <form-bean name="userForm" type="com.ebg.formbean.UserForm" />
    </form-beans>

    - <!-- ========== Action Mapping Definitions
    ==============================
    -->
    - <action-mappings>
    - <action path="/addUser" name="userForm"
    type="com.ebg.actions.AddUserAction" scope="request" validate="true"
    input="fail">
    <forward name="success" path="/work/blackListSearch.jsp" />
    <forward name="fail" path="/displayUser" />
    </action>
    <action path="/displayUser" scope="request" forward="/work/
    addUser.jsp" />
    </action-mappings>
     
    ramakrishna, May 8, 2007
    #1
    1. Advertising

  2. ramakrishna

    Tarkin Guest

    Re: struts html:form resolving action with double slashes

    On May 8, 11:01 am, ramakrishna <>
    wrote:
    > Dear all,
    >
    > I have a problem in html:form form tag.
    >
    > Iam using following html code.
    >
    > <html:form action="/addUser.do">
    > </html>
    >
    > while resolving the aciton it is giving the following result.
    >
    > <form method="post" name="userForm" action="//addUser.do">
    > </form>
    >
    > Iam getting "//addUser.do" double slashes in action element.
    >
    > Could you please send me the solution for this.
    >
    > Please send me reply.
    >
    > Thanks In Advance.
    >
    > Please find the struts-config.xml entry
    >
    > - <form-beans>
    > <form-bean name="userForm" type="com.ebg.formbean.UserForm" />
    > </form-beans>
    >
    > - <!-- ========== Action Mapping Definitions
    > ==============================
    > -->
    > - <action-mappings>
    > - <action path="/addUser" name="userForm"
    > type="com.ebg.actions.AddUserAction" scope="request" validate="true"
    > input="fail">
    > <forward name="success" path="/work/blackListSearch.jsp" />
    > <forward name="fail" path="/displayUser" />
    > </action>
    > <action path="/displayUser" scope="request" forward="/work/
    > addUser.jsp" />
    > </action-mappings>


    I don't think you have to use the '/' in the tag, especially
    if it's a globally-mapped action. I'm not 100% certain on
    this; it's just a guess. Check the docs or API for
    the html:form tag.

    HTH,
    Tarkin
     
    Tarkin, May 8, 2007
    #2
    1. Advertising

  3. ramakrishna

    Tim Slattery Guest

    ramakrishna <> wrote:

    >Dear all,
    >
    >I have a problem in html:form form tag.
    >
    >Iam using following html code.
    >
    >
    ><html:form action="/addUser.do">
    ></html>
    >
    >while resolving the aciton it is giving the following result.
    >
    ><form method="post" name="userForm" action="//addUser.do">
    ></form>
    >
    >Iam getting "//addUser.do" double slashes in action element.


    I can tell you that we don't use a leading "/" in the 'action" names
    in our tags. Struts prefixes the appname and a leading slash. This
    tag:

    <html:form action="entryFormUpdate.do" styleId="updform"
    scope="request">

    renders this way:

    <form name="EntryFormBean" method="post"
    action="/CES/entryFormUpdate.do" id="updform">

    --
    Tim Slattery

    http://members.cox.net/slatteryt
     
    Tim Slattery, May 8, 2007
    #3
  4. ramakrishna

    ramakrishna Guest

    Re: struts html:form resolving action with double slashes

    I got the solution..

    I'm using Tomcat 5.0.19 and Struts 1.1 on W2K.

    My problems started when I moved my web application from a context, to
    the
    container root.

    Struts generated urls with double leading slash such as //Login.do
    which
    caused all sorts of problems.

    My <html:form action="/myAction">

    generated <form action="//myAction.do">

    or if the page was in a module called test it generated

    <form action="//test/myAction.do">

    The problem? I had incorrectly deployed the application into the root
    by
    specifying the context path as / instead of null.

    Tomcat took it so I thought all was well, (a few <html:img> problems
    which I
    worked around by using <c:url...> ) but of course
    javax.servlet.ServletContext.getServletContextName returns what I
    typed (
    "/" ) and thus the double slashes.

    My incorrect <context> read:
    <Context path="/" docBase="D:/Website/" ... >

    and the correct one:

    <Context path="" docBase="D:/Website/" ... >

    Although it's pretty hard to search the archives (even google) for //
    double
    slashes maybe this will help someone else out.


    Tim Slattery wrote:
    > ramakrishna <> wrote:
    >
    > >Dear all,
    > >
    > >I have a problem in html:form form tag.
    > >
    > >Iam using following html code.
    > >
    > >
    > ><html:form action="/addUser.do">
    > ></html>
    > >
    > >while resolving the aciton it is giving the following result.
    > >
    > ><form method="post" name="userForm" action="//addUser.do">
    > ></form>
    > >
    > >Iam getting "//addUser.do" double slashes in action element.

    >
    > I can tell you that we don't use a leading "/" in the 'action" names
    > in our tags. Struts prefixes the appname and a leading slash. This
    > tag:
    >
    > <html:form action="entryFormUpdate.do" styleId="updform"
    > scope="request">
    >
    > renders this way:
    >
    > <form name="EntryFormBean" method="post"
    > action="/CES/entryFormUpdate.do" id="updform">
    >
    > --
    > Tim Slattery
    >
    > http://members.cox.net/slatteryt
     
    ramakrishna, May 9, 2007
    #4
    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:
    952
    Sudsy
    Aug 3, 2003
  2. qazmlp
    Replies:
    5
    Views:
    712
    Michael Dunn
    Apr 7, 2004
  3. Sydex
    Replies:
    12
    Views:
    6,602
    Victor Bazarov
    Feb 17, 2005
  4. John
    Replies:
    0
    Views:
    986
  5. Dan Wilkin
    Replies:
    1
    Views:
    272
    robic0
    Jul 17, 2006
Loading...

Share This Page