MVC with Struts?

If you are going to implement the MVC pattern in a webapp, what is the best framework to use?

I've done a tutorial with Struts. Is that a good framework?

Is there any disadvantages by using such frameworks?

[227 byte] By [vatora] at [2007-11-27 10:18:19]
# 1

> If you are going to implement the MVC pattern in a

> webapp, what is the best framework to use?

Define "best". The one you know best is recommended.

> I've done a tutorial with Struts. Is that a good framework?

It's certainly popular. I think it's one of the first attempts at solving the problem in a general way, along with WebWorks.

Struts incorporates a number of ideas that are part of all web MVC frameworks now: a front controller servlet to handle all requests, URL-action-page flow mappings externalized into XML, validation, mapping of HTTP requests into objects, etc.

> Is there any disadvantages by using such frameworks?

There are disadvantages to everything, depending on how you use them. I don't care for Struts because it's easy to tie the web tier too closely to the business logic. If you put all your business logic into the Action class you can't use any of it WITHOUT Struts. I would recommend injecting a separate service layer to decouple the business logic from web tier. It's easier to make it service oriented that way, too.

Personally, I prefer Spring these days. I think the web MVC is better than that of Struts, and it provides so much more besides. Struts is just web mvc framework. Spring is a more general Java EE framework based on dependency injection and aspect-oriented programming.

%

duffymoa at 2007-7-28 16:28:00 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Hi,

Since you are looking for a MVC framework, just have a look at Spring MVC framework as well. It does not have those dependencies like StrutsForm, StrutsAction, etc.

Cheers,

Kamal

http://lkamal.blogspot.com

Kamal-Mettanandaa at 2007-7-28 16:28:00 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

I've done a handful of projects in Java and in different frameworks.

Most that I've developed were in struts.

Although Struts is a good framework, it still has lots of pitfalls.

I think Spring is a better framework than Struts because it has resolved the plages on the Struts framework.

It is the main reason why the founder of the Spring framework has created the said framework... because he is too incensed with Struts..

Hope this helps...

-- WraithStrider

http://www.WraithStrider.com

Wraithstridera at 2007-7-28 16:28:00 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

> It is the main reason why the founder of the Spring

> framework has created the said framework... because

> he is too incensed with Struts..

>

Nah. He created it to take advantage of services typically provided to EJB, without having to conform to the EJB spec, or use an EJB container. If you read his trilogy of adverts for Spring, he makes this point quite often. The MVC part of the framework, yes, was in response to failings Johnson saw in Struts, but the idea for Spring was to move away from the EJB component model

read (in order)

http://www.amazon.co.uk/Expert-One-Design-Development-Programmer/dp/0764543857/ref=pd_bbs_sr_1/203-9475296-9476717?ie=UTF8&s=books&qid=1184339340&sr=8-1

http://www.amazon.co.uk/J2EE-Development-Without-Expert-One/dp/0764558315/ref=pd_bbs_sr_3/203-9475296-9476717?ie=UTF8&s=books&qid=1184339340&sr=8-3

http://www.amazon.co.uk/Professional-Java-Development-Spring-Framework/dp/0764574833/ref=pd_bbs_sr_2/203-9475296-9476717?ie=UTF8&s=books&qid=1184339340&sr=8-2

to see how Spring came about. Still don't know where the name came from, though :-/

georgemca at 2007-7-28 16:28:00 > top of Java-index,Other Topics,Patterns & OO Design...
# 5

> Nah. He created it to take advantage of services

> typically provided to EJB, without having to conform

> to the EJB spec, or use an EJB container.

This is correct.

If you look at Spring, you'll see that it easily integrates with Struts if you prefer it to Spring MVC.

If it were true that Rod Johnson was that angry with Struts, it's unlikely that he would have allowed Spring to interact with it.

%

duffymoa at 2007-7-28 16:28:00 > top of Java-index,Other Topics,Patterns & OO Design...
# 6

> If you are going to implement the MVC pattern in a

> webapp, what is the best framework to use?

>

> I've done a tutorial with Struts. Is that a good

> framework?

>

> Is there any disadvantages by using such frameworks?

I will suggest you to go wid webwork or Struts2 action framework (its different thn struts 1.3)

It provides many advance futures like, interceptors, typeconversion n many more

sudhir

http://www.jyog.com

Sudhir_nimavata at 2007-7-28 16:28:00 > top of Java-index,Other Topics,Patterns & OO Design...
# 7

> If you are going to implement the MVC pattern in a

> webapp, what is the best framework to use?

None if you can do without it. The best solution is always the simplest. But you'd have to provide some requirements to get a better answer. Let me just say I've seen many projects that simply read/write small amounts of data from the database and display it on a web page, yet the architect will throw in struts, hibernate, etc. and almost all of the time (IMO) it's overkill.

> I've done a tutorial with Struts. Is that a good

> framework?

Some people love it. Some people hate it. IMO it has many, many problems and I don't care for it one bit. However, it's very popular and lots of people use it, so it's not a bad skillset to have.

> Is there any disadvantages by using such frameworks?

There are tons of disadvantages:

1. The API is external (i.e. out of your control) so when it breaks you can't do anything but hack the source.

2. Performance can be a problem, since you've got an extra layer of software to run through, but usually isn't. Struts for example isn't going to bog you down.

3. It costs time (i.e. $$$) to train and come up to speed on how to use these frameworks. If you already know Java and have a small project you could likely complete it in the time it'd take you to learn struts.

4. Compatibility. When the latest version of struts comes out for example, you might want to upgrade to get the latest features, but you might find it breaks the old API and now you have to fix a bunch of code because it's not backwards compatible. That's probably rare, but it's happened to me more than once with struts.

5. Struts documentation (IMO) is horrible (maybe it's better today? i haven't used it in awhile) and it's not fun to learn.

6. Struts error messages are ridiculous and it's often very difficult to figure out what went wrong. Whereas in core Java I find the error messages to be very helpful in telling me what I did wrong.

The list goes on and on and on. Frameworks are bad news for many projects and then again they are saviors for others.

SoulTech2012a at 2007-7-28 16:28:00 > top of Java-index,Other Topics,Patterns & OO Design...