aspose file tools*
The moose likes Struts and the fly likes why ActionForm and not HttpSession Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "why ActionForm and not HttpSession" Watch "why ActionForm and not HttpSession" New topic
Author

why ActionForm and not HttpSession

vaidehi Agate-keskar
Greenhorn

Joined: Apr 18, 2009
Posts: 12
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Apr 18, 2009
Posts: 12

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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Apr 18, 2009
Posts: 12
Thanks a lot! One more question about Action classes:

why to write execute method in Action's subclass?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

So your application has functionality.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why ActionForm and not HttpSession