struts html:form resolving action with double slashes

R

ramakrishna

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>
 
T

Tarkin

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
 
T

Tim Slattery

ramakrishna said:
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">
 
R

ramakrishna

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top