I am fairly new to struts and want to learn how to do things the "right"
way.  Unfortunately, I haven't found a definitive, practical answer from
looking at the example webapps, so I am hoping a more experienced user could
give me some advice, which I promise to pass on to others :-)

I am getting up to speed on struts by programming a small application that
has only one JSP page.  Whenever you visit this page (/index.jsp), it will
fetch some headlines from across the Web using a SOAP call.  The code to do
the SOAP is neatly packaged in a jarfile, and for simplicity, let's say it
works like this:

        Headlines h = new Headlines("http://www.foo.com/headlines";, 10);

where the parameters are the site to get the headlines from and the number
(int) of how many headlines to fetch.

When someone goes to the /index.jsp page for the first time, I want to
populate the page with headlines using the default values above.  On that
same page, I want them to have the ability to choose a site from a select
box and type a number of headlines to fetch in a text box.  This page will 
just submit back to itself.

I know that I need a form bean to handle getting the form values to the
class to fetch the headlines, but my questions are:

1.  How do I populate it the *first* time a user visits the page (before any
form is filled out).  Do I just make the form bean's default value for
URL="http://www.foo.com/headlines"; and the default value for numHeadlines=10
?

2.  I simplified the work behind the SOAP call to explain my point, but do I
put the actual code (about 20 lines) for making the call into the
ActionClass?  Or do I put it into the FormBean somehow?  Or somewhere else? 
Should the code that catches and handles exceptions go there too?

3.  How do I make the Headlines object available to the JSP page?  As a bean
put into session scope?

4.  Should the URL that I advertise to users be /index.jsp or should it
match the action, like /showArticles.do ?  I know it's a best practice to
use /do/ rather than *.do, but I want to keep it simple for the moment.

5.  What might the struts-config.xml look like for this type of action?

Thanks *very* much for any help you can give.  After I finish this example
app, I plan to make it (and the source) available for others to look at for
guidance.

Tom

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to