This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes what if I replace the Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply 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: 1002
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: 4725

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://zeroturnaround.com/jrebel
 
subject: what if I replace the "html:form" by "form"?
 
Similar Threads
more questions about session and encodeURL()
How to customize mapping in struts-config.xml ?
Empty Action Form
which part does sturts "encodeURL"
can i use a normal form with struts?