File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes what if I replace the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "what if I replace the "html:form" by "form"?" Watch "what if I replace the "html:form" by "form"?" New topic
Author

what if I replace the "html:form" by "form"?

Artemesia Lakener
Ranch Hand

Joined: Jun 21, 2005
Posts: 162
I replaced the <html:form> by <form> and in the "action" tag I do

action="<%= response.encodeURL("....") %>"

Let's temporarily not discuss *why* I do this. I have a question --- If I use <form> to replace it, how about those "forward" defined in the "struts-config.xml", does struts still automatically apply "encodeURL" for those forward for me ? Or do I have to apply "encodeURL" to those "forward" by myself because I am not using <html:form> ??
Artemesia Lakener
Ranch Hand

Joined: Jun 21, 2005
Posts: 162
actually, bear with me for one more question here --

if I use <FORM> in JSPand I have sessions, should I append "encodeURL" to the "ACTION" or not ? Maybe I don't need to as maybe struts handles that for me too. I know struts handles it automatically if I use <html:form> tag, but how about I use <FORM> html tag ?
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
The html:form tag will do several things for you (apart from just creating the <form> tag on the page with appropriate action)

- create your action form bean and exposes to the page
- allow you to use tags like <html:text property="userName"/> with an implicit form (ie the form is provided by the html:form tag.)


>does struts still automatically apply "encodeURL" for those forward for
>me ? Or do I have to apply "encodeURL" to those "forward" by myself
>because I am not using <html:form> ??
Forwards in the struts:config do not need to be encoded.
The point of encodeURL is so that a sessionId can be included in the URL if the browser does not support cookies. It is only necessary if the URL is going to be rendered onto a JSP page - either as a form action, or a href in a link. For forwarding with the request dispatcher, encoding the URL is pointless.

>if I use <FORM> in JSPand I have sessions, should I append "encodeURL" to the "ACTION" or not ?
Yes. The html:form tag will automatically call encodeURL on the action attribute. If you are writing your own form tag, with its custom action, you have to encode it yourself.

Cheers,
evnafets
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Artemesia Lakener:
Let's temporarily not discuss *why* I do this.


The discussion may lead to a better solution.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what if I replace the "html:form" by "form"?