Java Programming - A few problems using beans.....

Where to start...

Well, I have got a servlet that creates a new instance of a bean ('generalBean'), then the 'generalBean' runs a query within the DB it connects to. Then 'while(resultSet.next)' it creates an instance of another bean called 'detailedBean' and sets all the variables it has ('v1', 'v2', 'v3').

Now I want the 'generalBean' to return control back to the origional servlet. I know I need a 'return()' command in, but im not really sure what I am supposed to be returning. And it gives an error when I just type 'return()'

End of problem 1

Now once that is done, I need to be able to have the origional servlet (that control has just been passed back to) to check if the 'generalBean' has found any results (and therefore created some instances of 'detailedBean').

If it has, then go to a jsp page, where (somehow) the jsp page will 'include' something, that will walk through each 'detailedBean' and retrieve all the results.

End.

I have been struggling with this for hours now and haven't got a clue where to go on this one. Im not an expert at this yet, so please exlain anything in as much detail as possible.

Thanx

CKS

[1229 byte] By [CKS1a] at [2007-11-26 23:21:27]
# 1

Well just simply got rid of the 'return()' statement, and got rid of most of the other errors. But still 2 that aren't working.

**myBean myBean = (myBean)session.getAttribute("myBean");

**myBean = new myBean();

On the first line, it doesnt like the part '(myBean)' and '("myBean")'

On the second line, it doesnt like the 'myBean()'

:(

Any help?

thanx

CKS

CKS1a at 2007-7-10 14:25:41 > top of Java-index,Java Essentials,Java Programming...
# 2

I may be wrong but I think you cannot have a return statement in your beans. Methods will be void.

Secondly, how are you creating an instance of your bean class ? Did you check how to intantiate a bean class in a JSP page?

I have done it the other way, not like yours in my application.

like :

<jsp:useBean class = "formjavabean.application" id = "applicationId" scope = "session" />

and then you can call the bean method like this :

<% String userEmail = applicationId.getUserEmail() ; %>

I hope this might help,

good luck

NasirMunira at 2007-7-10 14:25:41 > top of Java-index,Java Essentials,Java Programming...