Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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



The discussion may lead to a better solution.
 
Let me tell you a story about a man named Jed. He made this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic