Greetings!

First, I'm new to Struts, and pretty green in my Java skills, but I'm
excited about learning both!

My goal is to retrieve data, which a jsp will spill out. I'm trying to
do it by writing a simple Action subclass to get the data and send it
along. The way I'm doing it isn't working.

My action mapping looks like this:

<action
        path="/records"
        type="app.actions.RecordsAction"
        forward="/pages/records.jsp" />


My app.actions.RecordsAction looks approximately like this:

public class RecordsAction extends Action {

        public ActionForward execute(ActionMapping mapping,
                ActionForm form,
                HttpServletRequest request,
                HttpServletResponse response)throws IOException, 
ServletException{
                
                RecordList rl = new RecordList();     //Object used to get 
records
                List l = rl.getRecords();
                request.setAttribute("records",l);
                return  mapping.findForward("could-be-anything");
        }
}

The result is that I get forwarded to /pages/records.jsp without the
"execute" method ever being called in RecordsAction, and as such, I
get a null pointer when I try to do anything with the
request.getAttribute("records") in the jsp. However, this seems to
make perfect sense because I specified this to merely forward. So, how
do I get the data?

If I want to simply return dynamically generated content, without an
ActionForm, what's the best practice for retrieving it?

1.What should the Action subclass look like?
2. What would the <action-mapping> in struts-config.xml look like?
3. Is it common to use request.setAttribute("value") to send data to
the View? and if not, what's the correct way to send data to the View
layer? (I think this is the pivotal question)

I've been going through Struts in Action, which I find good as a
technical reference, but not so good when it comes to figuring out how
to achieve a simple goal, like this. In my quick research in the book
and online, everything I've found seems to be tied to ActionForms. But
I don't have an ActionForm. Alas!

I realize that I am probably missing something fundamentally basic and
that y'all might tell me to go RTFM. And that's cool, just point me to
it. Most of the stuff I've seen is very focussed on dealing with data
AND forms, but not data by itself. I'd be happy to find some
recommended documentation.

Thanks for your collective help in getting me on track!

Eric Rank

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

Reply via email to