Discussions

Web tier: servlets, JSP, Web frameworks: Action Form Scope in Struts

  1. Action Form Scope in Struts (5 messages)

    Hi,

    I have read that an ActionForm can be programmed to different scopes - request or session.

    But the struts-config.dtd does not mention the form-bean having a "scope" attribute.

    Where can the form be scoped then?

    Thanks for your time,
    Abraham

    Threaded Messages (5)

  2. Action Form Scope in Struts[ Go to top ]

    Hi,

    >
    > I have read that an ActionForm can be programmed to different scopes - request or session.
    >
    > But the struts-config.dtd does not mention the form-bean having a "scope" attribute.
    >
    > Where can the form be scoped then?
    >
    > Thanks for your time,
    > Abraham
    Normally formbean is associated with the Action and Action element has an attribute "scope" where the scope of the ActionForm is specified. Look under action element in the dtd file for more info.
  3. Action Form Scope in Struts[ Go to top ]

    You can use the same action form for many actions and specify the scope for each action as it is needed.

    Many developers associate ActionForm classes (form beans) to a single action when they are instead very reusable classes. That is why the scope is not identified in the <form-bean> tag but instead in the <action> tag where it will be used.

    Cheers,
    Mathieu
  4. Another Question[ Go to top ]

    As I understand it the best practice is to limit the amount of information you store in the session scope this doesn't always get cleared out and can effect performance.

    1. Is there a pattern that allows you to define your own scope - between session and request which will be cleared out at a specified point?

    2. When you are gathering information on a number of pages should you use one big formbean on a number of small ones?
  5. There is no other area other than session request or application you can write data. For your problem you can write a crown job which can check if there is any thing you want to remove you can. Set a timeout at which the data will be cleaned. The crown job will delete the session objects when timeout reaches.

  6. You can always give request scope to your form bean in struts-config file when you map the action . In fact its a good practice and makes the session lighter