My perspective is that there is still value in having an ActionForm for that example. I generally think it is best for your Actions to pass information to the JSPs that render them through an ActionForm rather than putting things in the request or session directly. For this reason, I think it would be better to put the current time into an ActionForm than to stuff it into the session. Struts will put your ActionForm in the request or session for you; your Action need only populate it with data, and then the JSP can expect to find your well-defined ActionForm in the scope specified in the struts-config.xml file. It doesn't matter if there is no data coming in on the request for Struts to pre-populate the ActionForm. Using an ActionForm still has value in that it defines what the JSP can expect to find, and where.
Opinions on this topic surely vary (i.e. I am sure some people will disagree with my recommendation here), and I have seen a lot of Actions and JSPs that communicate via request and session attributes that aren't defined in the struts-config file. But I prefer to limit the communication between the Action and the JSP to a well-defined ActionForm in a well-defined scope to the extent that it is possible. I view the Action/JSP coupling that comes with passing otherwise undefined request and session attributes to be undesireable. I think it is better to keep the interface between these components (a specific ActionForm in a specific scope) well defined (by specifying it in the struts-config.xml file). -Max ----- Original Message ----- From: "Masashi Nakane" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, February 04, 2004 5:00 PM Subject: Action without ActionForm > > Hi ,all > > I am new to Struts and learning it. > > And I am wondering how the strtus-config.xml and JSP look like when > a JSP doesn't submit any info( dont need ActionForm) . > > The JSP just display the current time and has one button "refresh". > > CurrentTime.jsp ( user push refresh button) > -> CurrentTimeAction(get current time and put it to Session Attribute) > -> CurrentTime.jsp ( get time from Session and render) > > I have made the JSP without Struts framework . it works . > > but I have no idea how I can make this with action mapping in struts-config.xml. > I made the mapping below and I got error when I try to open the JSP . > JSP is using <html:form> tag to make form. > > javax.servlet.jsp.JspException: Cannot retrieve definition for form bean null > > but i dont need any ActionForm > --------------------------------------------- > <action-mappings> > <action path="/currenttime" type="com.somecompany.CurrentTimeAction"> > <forward name="success" path="/CurrentTime.jsp" /> > </action> > </action-mappings> > ----------------------------- > I have already checked the which attribute of action tag is mandatory or > optional . > Should I make dummy ActionForm ? > > > Any comments are appriciated. > > Masashi Nakane > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]