Best way to pass "return info" from a method (DAO to Controller) e.g

Hello all. I have a MVC type setup for a system I am developing and I am having a few problems with return info.

The controller calls methods from other classes and they always return something, mostly strings. But sometimes I need to return multiple strings, e.g username, password, location, etc.

So when I call the method from the controller I simply pass the request object to it and the method does its thing. But I tried returning objects but they always come back as null when I access them from the controller.

Say I added some strings to the request object formRequest from the DAO for them to be returned to the controller for further manipulation, how should I do it ? I tried using "return formRequest" but it comes back null when the controller tries to access "formRequest" and if I try to use "request" on compile it says the variable request does not exist.

To access a method returned object, what should the syntax be ?

I don't want to have to create objects as attributes of the DAO so I can access them from the controller, i.e testDAO.attributeName, but this is the only way I can see to get access to these objects.

Should I use the requestDispatcher ?

Any help appeciated.

[1245 byte] By [MrVenjera] at [2007-11-26 16:19:45]
# 1

Ok, I just read that using request.setParameter and getParameter I can pass strings easily but to pass objects I need to use request.setAttribute and getAttribute and use the requestDispatcher to pass it to the servlet.

The question I have then is ..... if my controller calls a method in my DAO class which adds the relevant object(s) to the request object, what do I put in the requestDispatcher to make the flow or sequence of events correct ?

Example, a user submits a form, the form uses a case/switch block in the Control servlet which itself will call a method in the DAO class. The DAO class needs to pass information back to the Controller which manipulates the data and readies it for output to a jsp. I need the Controller to continue where it left off WITH the returned data !!

Any thoughts ?

MrVenjera at 2007-7-8 22:43:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...