File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts with Spring and Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts with Spring and Hibernate" Watch "Struts with Spring and Hibernate" New topic

Struts with Spring and Hibernate

Brian Hazzard

Joined: Apr 26, 2007
Posts: 8
My current mode of working with Java is very much as a desktop application programming language. When I need to develop a web application I tend to think PHP with a cool framework (like Qcodo) to keep it well designed and organized. But I long for one platform that can do it all, and while I know that Java can fill that void, I have always found Java to be cumbersome as a web application language.

In my research I have heard a lot of buzz about the stack of Java with Hibernate, Spring and Struts, but I cannot honestly say I understand each framework's role in implementing a web app. Could someone please help me clarify the role of Struts in web applications?

Thank you,

sita raman subra
Ranch Hand

Joined: Apr 09, 2007
Posts: 47

Struts is a framework which is developed using the patterns like FrontController,Command patterns etc.So it will help you to process the request and response without doing much Scatter coding.You just need to configure the details in the xml.

Hibernate is also a open source framework used to develop a DAO layer.Again it will evade you from handling the statements.So atlast our application become database independent.

Spring is a mammoth frame work which have the various functionilty.Its upto you to decide how to use the SPring in your application.You can use it as a frame work or for persistent etc...

Thanks & regards,
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 471

Hello Brian,

Struts, spring and hibernate are three totally different frameworks. Since this is the struts forum, let's start with it. Struts is a web application framework that implements the front controller design pattern. Basically, there is a servlet which gets the users' requests, and decide which java class should handle this request (a struts action), and according to the result of this class' processing, which JSP should be processed to return output to the user. The front controller (the servlet) decides what to do according to a configuration file (typically called struts-config.xml). This is of course the most basic idea, but struts is much bigger than that. It has a validation framework to aid you validate the data entered by the users, and the tiles framework which helps you create custom complex layouts for your web application using simple JSPs glued together. Many more features are present.

Hibernate is an object relational mapping framework, meaning that instead of working with relational databases using JDBC, result sets, and all this complexity, you will be working with plain old java objects, without the need of writing a single SQL command. You map your database tables to your domain objects using XML mapping files. Using the configuration file, you can tell hibernate which SQL dialect to generate, as well as which data source.

Spring is, IMHO, the BEST enterprise framework ever. The core of spring is an inversion of Control (IoC) container, which helps you follow one of the best design principles, and that is to code to interfaces and not concrete classes. Spring has many modules, and one of the best features it has is that it can integrate with nearly any other framework it may need. It also provides some great templates to help you reduce the unnecessary code you write, and concentrate more on your application logic. You want JDBC? Use the JDBC template so that you don't have to create a connection, open it, then close and release it after you're done. You want hibernate? Use the hibernate template so that you don't have to create a session, open it, create a transaction, commit the transaction and close the session after you're done. Transaction management? You got it. Mail? No problem. You would practically find anything you might need in the spring framework, or at least you would find integration with the framework of your choice, with lots of utilities to make your life easier.

Hope this clarifies things for you, and sorry for the long post.

Visit my blog:
I agree. Here's the link:
subject: Struts with Spring and Hibernate
It's not a secret anymore!