• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access DAO from jsp

 
pemi ola
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I am working on a Struts based application and I have created DAO for use with getting data from a DB.

My problem is I dont know how to display my DAO parameters in the JSP. I have tried reading up tags but all I get is bean tags. DAOs are not beans

I have tried using the following code in my jsp but it doesnt work



Can anyone please help me?
 
Duddiyanda Siraj
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest, first understand What is Data Access Object (DAO) layer is used for, also what is the purpose of calling DAO in JSP
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a complement to the Siraj's post, DAO is something comes under Data Access Layer. Using DAO directly in JSP is something like killing the purpose. You are mixing the Presentation Layer with Data Access Layer.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adeel Ansari:
Using DAO directly in JSP is something like killing the purpose. You are mixing the Presentation Layer with Data Access Layer.


agree with adeel.
do separate presentation from business logic, follow this for best practice and also makes your code more maintainable.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Saif uddin:
do separate presentation from business logic, follow this ...


Its better to replace "business logic" with "data manipulation logic", I suppose. Nonetheless, agreed.
 
pemi ola
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks all,

I will try and do as adviced.

But here is the scenario, I already have my DAO's, I have a blank struts application. I am building business logic and I dont want to start re-inventing the wheel.

I was hoping that I wont have to bog down the application with extra java classes to pass through.

Are you all suggesting that I leave my DAO's out of jsp's completely and instead create java beans that can use the DAO resources?

Please point me in the right direction.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to suggest few readings.

MVC, DAO, Transfer Object
[ February 14, 2007: Message edited by: Adeel Ansari ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic