• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Struts and Hibernate how to display in jsp file  RSS feed

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi brent,
thanks a lot, I figured it out, it works how I want it to work

thank you, have a nice day

regards
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!