aspose file tools*
The moose likes JSP and the fly likes Access DAO from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Access DAO from jsp" Watch "Access DAO from jsp" New topic
Author

Access DAO from jsp

pemi ola
Greenhorn

Joined: Feb 12, 2007
Posts: 2
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

Joined: Nov 11, 2004
Posts: 23
I suggest, first understand What is Data Access Object (DAO) layer is used for, also what is the purpose of calling DAO in JSP


Before every minute of action, there should be an hour of thought.<br />- Henry Ford
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Dec 06, 2005
Posts: 1321

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.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Feb 12, 2007
Posts: 2
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

Joined: Aug 15, 2004
Posts: 2874
I would like to suggest few readings.

MVC, DAO, Transfer Object
[ February 14, 2007: Message edited by: Adeel Ansari ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access DAO from jsp