Start by creating an action that would replace your servlet.  If the user
enters any parameters for the report then create a Form.  The "action"
attribute of the form would be your new action to execute the report.  The
action would define a FORWARD to the proper presentation .JSP page.  Once
the action executes, it creates a bean in the request context, and forwards
to the page specified in the configuration.  The page uses the Iterator and
other struts beans to display the final report to the user.

This will work fine as long as the report is not too large.  If the report
is thousands of pages long, your JVM might run out of memory before the bean
is finished initializing.  That's a bigger problem.  You would need to
implement paging support.  But start simple, and see how that works out for
you.

-AP_
http://www.alexparansky.com
Java/J2EE Architect/Consultant
http://www.myprofiles.com/member/profile/apara_personal

-----Original Message-----
From: Malcolm Dew-Jones [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 30, 2002 2:26 PM
To: Struts Users Mailing List
Subject: Q: Converting simple report app to struts.


Hello...

I have a small web app that displays some reports and extracts some data
(from a database) and have been tasked with converting it to be a struts
application.

My problem us that it's not clear in my mind how to merge the application
into the MVC paradigm, and so I'm looking for suggestions or examples on
the layout of the logic internals of a simple "reporting" application such
as this (its classes etc).

The current app has some html pages, one jsp, and one servlet.

The home page is just an HTML that asks what kind of report the user
wants.  The user does not need to login, or provide any explicit input to
access anything.  The main page links to several more html pages, which
display some geographic maps (as <MAP>'s).  The user clicks on a region
within a map and that links to the single JSP with two parameters, the
type of map (climate, political, or terrain) and the code for the selected
area.

The single JSP generates all the reports, which are identical in layout,
and simply come from different views (the views are also all identical
except that they categorize various sets of data in numerous ways).

The JSP uses an Oracle cache bean in application scope to login to the
database. The user does not need to login as such, anyone can access the
JSP, all connection info is contained in a config file that the JSP reads
to get the user and password.  The JSP builds a SELECT statement that
selects from the correct table, and then loops over the rows of data,
embedding many of the columns as <TD>'s in a <TABLE>.

The JSP also has a link to a servlet that will dump the underlying data in
CSV format.  The servlet takes the same two parameters as the JSP, and
builds a similar SELECT statement to select the underlying data, and then
loops over each row, outputing it in CSV format.  The servlet uses the
same cached connection class as the JSP to login to the database.  The
same login parameters are read during the servlet's init() method, though
for some reason the pool of connections the servlet uses is always a
different pool than the JSP.

I'm supposed to rewrite this as a struts application, but as I said, I'm
not sure how to apply the MVC pardigm to this.  What things should be done
by (any?) jsp, and what things should be action classes, and since the
input parameters are never "saved" for later, how does this fit into the
form class paradigm, etc etc.  - and where in the struts "arrangement"  of
things do I create a single pool of connections that can be used by a(ny)
JSP or servlet?

Suggestions welcome, or pointers to good examples of a simple report
display application using struts.  If it makes a difference, this will
be run under the "Oracle 9iAS server using OC4J J2EE container" - I
think this is more simply called the Orion server.

Thanks, Malcolm Dew-Jones



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



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

Reply via email to