Hi,
I am just starting with struts and I experienced problems already. What I am doing is, forwarding (in the index.jsp) to a Startup action, which decides whether to forward to a login page or to a normal "insider" page.
If it forwards to the login page, in the form (created with <html:form> the Action request starts with two slashes, not with one. This leads to problems with the browser because the complete URL then only consists of something like http://Login.do;jsessionid=xyz...
I created a <html:link> element with the same target as the form action, and there it works fine (only one slash).
Working fine also means that there seems to be some validation where the errors are printed in the page which I interpret as "the action was invoked".
I use Tomcat 5.0.28 and struts 1.2.4. Tomcat is configured to have multiple hosts, where each host has it's own single web application in the root ("/") context.
Has anyone any idea?
Thanks, Jan
This is my struts-config
This is the initial forward, used in the index.jsp
<global-forwards>
<forward name="welcome" path="/Startup.do"/>
</global-forwards>
Here the actions are defined.
<action-mappings>
<action path="/Startup" type="org.biotrull.moviedatabase.Startup" scope="request">
<forward name="login" path="/pages/Welcome.jsp"/>
<forward name="movies" path="/pages/movies.jsp"/>
</action>
<action path="/Login" type="org.biotrull.moviedatabase.Login"
name="LoginForm" scope="request" validate="true"
input="/pages/Welcome.jsp">
<forward name="success" path="/pages/movies.jsp"/>
</action>
</action-mappings>
And the form bean for the login form.
<form-beans>
<form-bean name="LoginForm" type="org.biotrull.moviedatabase.LoginForm"/>
</form-beans>
Here is the code from the login page where I create the form and the link:
Here the action expands from "Login.do" to "//Login.do" in the generated HTML source (I already tried it without the .do)
<html:form action="/Login.do" method="post">
<html:errors/>
<table>
<tr>
<td>Login:</td>
<td><html:text property="login" size="30" maxlength="255"/></td>
</tr>
<tr>
<td>Password:</td>
<td><html:password property="password" size="10" maxlength="10"/></td>
</tr>
<tr>
<td> </td>
<td><html:submit>Submit</html:submit></td>
</tr>
</table>
</html:form>
</body>
<!-- this one works fine -->
<html:link page="Login.do">test</html:link>
Discussions
Web tier: servlets, JSP, Web frameworks: Struts: action path (two slashes) in generated HTML form
-
Struts: action path (two slashes) in generated HTML form (5 messages)
- Posted by: Jan Kaiser
- Posted on: November 16 2004 17:19 EST
Threaded Messages (5)
- Struts: action path (two slashes) in generated HTML form by Duncan Mills on November 17 2004 08:16 EST
- Struts: action path (two slashes) in generated HTML form by Jan Kaiser on November 17 2004 13:04 EST
-
Why? by Duncan Mills on November 19 2004 11:42 EST
-
Why? by Jan Kaiser on November 20 2004 09:32 EST
- what is the path of your root context? by dirk de kok on December 15 2004 02:09 EST
-
Why? by Jan Kaiser on November 20 2004 09:32 EST
-
Why? by Duncan Mills on November 19 2004 11:42 EST
- Struts: action path (two slashes) in generated HTML form by Jan Kaiser on November 17 2004 13:04 EST
-
Struts: action path (two slashes) in generated HTML form[ Go to top ]
- Posted by: Duncan Mills
- Posted on: November 17 2004 08:16 EST
- in response to Jan Kaiser
It should just be:
<html:form action="Login.do" method="post"> (no slash at all) -
Struts: action path (two slashes) in generated HTML form[ Go to top ]
- Posted by: Jan Kaiser
- Posted on: November 17 2004 13:04 EST
- in response to Duncan Mills
Thanks for your commend. I tried it without a slash in the form tag, but it leads to the same result.
I did some research in the struts sources and it looks like the FormTag adds the first slash from the context (which is the root context in my webapp) and the second slash by default.
The LinkTag uses another method to create the href value, which seems to be able to handle the case of a root-context webapp.
If I am right there is no workaround but to 'hack' the struts sources, which I would hate.
So if there is any suggestion helping me to avoid my private 'hack' I would be extremely happy ;-)
Jan -
Why?[ Go to top ]
- Posted by: Duncan Mills
- Posted on: November 19 2004 11:42 EST
- in response to Jan Kaiser
Any particular reason for wanting to put the application in the root context - is it really worth having to create a custom version of Struts for? -
Why?[ Go to top ]
- Posted by: Jan Kaiser
- Posted on: November 20 2004 09:32 EST
- in response to Duncan Mills
Yes, it is. I want to use Tomcat as Webserver directly and use its virtual host functionality to separate web applications on a single server, and avoid to use different paths in order to do so.
Besides that - I posted the bug to the struts bugzilla and it is accepted and meanwhile resolved.
This means, I do not have to maintain my private version of struts in the future an can stay with my root contexts.
Thanks for any suggestion. Regards! Jan -
what is the path of your root context?[ Go to top ]
- Posted by: dirk de kok
- Posted on: December 15 2004 14:09 EST
- in response to Jan Kaiser
hi there,
when I encountered the same problem I changed the path of the context, as a workaround . First it was path="/", now path="".
my config:
Tomcat 5.0.24 with Struts 1.1