You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Raley <jo...@moonlight.com> on 2001/04/02 20:04:32 UTC

Re: Basic design questions

Mike,

When you have a choice between returning something in the session and
returning it in the request, put it in the request.  Session data lives a
lot longer - it causes your per-user memory usage to go up.  Lots of
session data can also lead to hard-to-find bugs.

Does the bean bound to "searchForm" have a public method named
getResultString() that takes no arguments?

mike cannon wrote:

> Hi,
>
> I'm converting an existing servlet to use Struts and I have a design
> question.
>
> (WARNING: I don't even know JSP well; Please bear with me ;-)
>
> I want a single page that contains a query form and displays the most
> recent query results, if any, underneath.  (See search.jsp, below.)
>
> I wrote a SearchForm bean and a SearchAction class that extends
> Action.  Those seem to work fine.  SearchAction.perform() returns
> mapping.findForward("success") and search.jsp is re-displayed as
> planned.
>
> Here's my question:
>
>   How should I pass the results back from SearchAction to display
>   them in search.jsp?
>
> I can imagine setting an attribute in either the request or the
> session object.  In fact, what I *tried* to do is add a "ResultString"
> attribute to my SearchForm bean and display it using <bean:write...>
> below.
>
> I got an error: "bean ... has no getter method for "ResultString".
> Do I need to do more than add get- and set- methods in SearchForm?
>
> More to the point, is this even a sensible way to to this?
>
> TIA,
>
>  - Mike
>
> search.jsp
> ================================================================
> <%@ page language="java" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
>
>   <html:form action="search.do">
>
>       Name: <html:text property="Name" /><br/>
>
>       <html:submit value="Search" />
>
>       <br/><br/>
>
>       <!-- Now what ?
>       <bean:write name="searchForm" property="ResultString"/>
>       -->
>
>   </html:form>