• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Implementing Spring DAO concept in Struts MVC

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to Struts and Spring, I have developed a small registration application in Struts and it is working fine :D . I have also started learning Spring 2.5 and completed till Spring JDBC concept. I have succeeded in creating a standalone Spring JDBC main program which performs insert update and delete operations.

Now I want to remove all the boilerplate JBDC code from my Struts based registration application and integrate it with Spring JDBC.

Can someone please suggest me the right direction on how to implement this in Spring like how do I load the wiring information (beans.xml) into the application, how do i get the instance of the DAO Impl in the service object, what are the additional configurations I have to add in web.xml and struts-config.xml?

My beans.xml
***********
<beans>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
<property name="username" value="ora1"/>
<property name="password" value="oracle"/>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="manageUserDAO" class="com.regis.dao.ManageUserDAOImpl">
<property name="jdbcTemplate" ref="jdbcTemplate"/>
</bean>
</beans>
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.ibm.com/developerworks/java/library/j-sr2.html

(Although I don't know why you'd want to learn Struts 1 at this point unless you have a compelling reason to do so.)
 
yogi reddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave - Thanks a lot for your response. I really do not have any supporting reason to explain you why I started with Struts 1.3.8 but I am sure that I also want to learn Struts 2. Can you suggest any nice book for that (Though this is not the relevant forum to post this)?

I will try to add the Spring DAO to my existing struts application and see if it works.

Thanks,
Yogesh
 
yogi reddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave - I tried to implement the sping dao with struts and it worked. Thanks a ton.

Cheers,
Yogesh

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 2 in Action by Donald Brown, Chad Michael Davis, and Scott Stanlick is a good reference.
 
yogi reddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dennis - Thanks for your information. I will start with this material.

Cheers,
Yogesh
 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yogesh, what application were you build using Spring...can you share the guide (web site or etc) on how to develop that? Also if you find any sample step by step practical guidance for a building Struts 2 application please post it too.

Thank You.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a step-by-step walkthrough of a simple Struts 2 application on the Struts 2 documentation wiki.
 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 1.3.8, Struts 2 and Spring and completely different. It only makes sense to mix and match if you have reusable or legacy code.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mixing Spring with either makes perfect sense, though.
 
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring is so versatile, it can work with any major MVC framework. That is being said, how good is Spring MVC compared to Struts MVC. Any pros of using Spring with Spring MVC vs Spring with Struts MVC?

Thanks.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You avoid learning Struts.

Up until Spring 3.0 I've preferred Struts 2--but that's just a personal preference. (I haven't looked at the 3.0 stuff yet, so don't have any opinion.) If you're doing greenfield development it's solely a matter of technical and/or aesthetic preference, in my opinion--I think they're both really nice.
reply
    Bookmark Topic Watch Topic
  • New Topic