Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about the DOA conecpt with JSP  RSS feed

 
chester elegante
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

i'm quite new to java and have a question regarding the DOA concept.

so lets asume i've a db table filled with different food types (vegetables, fruits etc)

my understanding was that i'll have to build my webapp like this.

1. a java class to define the structure


2. a java class which does stuff


3. a servlet which combines stuff and calls the jsp


4. a jsp which shows stuff


the output would be

1 - Fruits
2 - Vegetables

no problems so far. but what if i want to list all the actual fruits and vegetables at the same page / jsp?

so i would get the following output

1 - fruits
1.1 banana
1.2 raspberry
...
2 - vegetables
2.1 potatoes
...

one thing i've tried is putting some java code in the jsp, which worked but i don't think thats a good solution



from what i understand putting sql / java logic in your jsp file is never a good idea

but how do i get this solved then?

i probably want to add a "third layer" which for example shows the last person who bought a banana

thanks in advance for helping me out

cheers

chester

 
Dave Tolls
Ranch Hand
Posts: 2815
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would expand your model to include the mapping to Food.

Your original class would become something like FoodGroup, which has a List<Food>.

Then the DAO might fully populate the FoodGroup classes with the Food that applies to them.

This is what the world was like before ORM frameworks like JPA/Hibernate.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!