This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts and Hibernate how to display in jsp file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts and Hibernate how to display in jsp file" Watch "Struts and Hibernate how to display in jsp file" New topic
Author

Struts and Hibernate how to display in jsp file

Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi,
I have the following problem, I have a function that makes a query over two tables and should return them as Collection or whatever and then display the results in a jsp page....

I have the following code so far...

the function:


the action form:


and the action form:



and I get the following error message if I execute that:



my problem is I don't know how to return the collection with the resultset and how to display it on the jsp page

thanks in advance
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Do you understand what "Collection[]" means? This means an array of Collection objects, which it does not look like you really want.

This line:
return (Collection[]) proPep.toArray(new Peptide[0]);

Should probably look like this:
return (Peptide[]) proPep.toArray(new Peptide[0]);

Though you might be better off just using Collection or List rather than converting to an array.

- Brent
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
dear Brent,
I select two attributes from two different tables..
The problem I have is to give back the attribute peptide_seq of type Peptide and the attribute name_of_protein of type Protein.

and I don't know how to do that...
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I don't fully understand your data model or what the page you are developing looks like. What if you create a class that could hold the two values and you then returned an array of those objects....like this:


- Brent
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi brent,
ok, thanks,
I have already a class Protein that contains the variable name and a class Peptide that contains the seq....
so I get two variables of a different type when I complete the select statement....the goal I want to achieve is to store both variables in a Collection or whatever and then to display it on a jsp page....

for that I thought to make a Protein_Peptide class that contains both variables with their getters and setters and to return a Protein_Peptide Array

thank you very much, but it works....thanks a lot.....

now I have to figure out how to display that in a jsp page.....
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi brent,
I got my jsp page to work, but it does not display any entries, altough the select statement is working, i have checked it on command line....
so I wanted to ask you whether I retrieve the information in the proper and right way...

jsp page:



the name of the form is how it is defined in the struts-config file
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi brent,
thanks a lot, I figured it out, it works how I want it to work

thank you, have a nice day

regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts and Hibernate how to display in jsp file