Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why ActionForm and not HttpSession

 
vaidehi Agate-keskar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am newbie to Struts. I have a doubt on ActionForm in Struts.
What is the exact use of actionForm? If it is used to store user specific data coming from HttpRequest then why can't we use HttpSession?
If it performs simple validations cant we use javacript for the same? And is it compulsary to use ActionForm?

Thanks in Advance.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vaidehi Agate-keskar wrote:What is the exact use of actionForm?


it gives the form input datas to the Action and vice versa . it is a bridge between the view and action.default it is in request scope. and mainly you should not put every thing into the session

vaidehi Agate-keskar wrote:If it performs simple validations cant we use javacript for the same?

you should not relay on client side validation

vaidehi Agate-keskar wrote:And is it compulsary to use ActionForm?

No.but preferable
 
vaidehi Agate-keskar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks seetharaman.

you should not put every thing into the session

Can you explain it in a bit detail?

And if it is not complusary to use actionForm but preferable, what else we can write instead of action form?

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vaidehi Agate-keskar wrote:
you should not put every thing into the session
Can you explain it in a bit detail?


one session per user .it is representation of an user [commonly contains user specification details] . if you put extra thing into that ,it may hit your web application performance ,if more users.

vaidehi Agate-keskar wrote:
And if it is not complusary to use actionForm but preferable, what else we can write instead of action form?


use <form> instead of <html:form> and validation="false" make it in your <action> tag of your struts-config xml

note: it is about struts 1.2
 
vaidehi Agate-keskar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot! One more question about Action classes:

why to write execute method in Action's subclass?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your application has functionality.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic