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

Why JSF and Struts together?

Adrian Pang
Ranch Hand

Joined: Feb 20, 2004
Posts: 40
When I read about JSF, the authors always stress that JSF does not replace Struts, and they are meant to work together. However, why would one want to do that? Doesn't JSF do everything that Struts does? What does Struts offer that JSF does not?

SCJP 1.4, SCWCD 1.4, SCBCD 1.3
David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
I also have the same question...I also found a "Struts-Faces" code base. What's that all about?
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
From the FAQ:
The inventor of Struts, Craig McClanahan, was a member of the expert group for the JavaServer Standard Tag Library (JSR 052) and is now the specification co-lead for JavaServer Faces (JSR 127). Both technologies are complementary to Struts.
The mainstay of the Struts framework is the controller components, which can be used with any Java presentation technology. As new technologies become available, it is certain that new "glue" components will also appear to help these technologies work as well with Struts.
Struts originally came bundled with a set of custom JSP tags. Today, several extensions are available to help you use Struts with other popular presentation technologies, like XSLT and Velocity. Likewise, extensions for JSTL and JSF are now available as well.
The JSTL reference implementation is available through the Jakarta Taglibs site. A JSTL taglibs for Struts, Struts-El , is available and distributed with Struts beginning with the 1.1 release.
Meanwhile, the JSF specification is still under development, although an early-release reference implementation is available through the Java Web Services Developer Pack. An early-release JavaServer Faces taglib for Struts, Struts-Faces , is also in early release and available through the nightly build.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Originally posted by Adrian Pang:
What does Struts offer that JSF does not?
A time-tested implementation? We have to remember that JSF is only now starting to become a viable choice for real-world applications. Struts has been around for years (although not for that many years).
In fact, Craig McClanahan has been suggesting that people should not migrate on-going Struts projects to JSF but should seriously consider using JSF for new projects.
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
I am doing some reading for JSF and looks like JSF by itself can not stand for a new project.
Definitely it needs to be "considered", but it should not be "considered by iteself".

SCJP, blog
Bill Dudney
Ranch Hand

Joined: Sep 05, 2003
Posts: 234
Hi Kishore,
JSF is intended to be used on its own. The Struts integration was initially used to provide navigation semantics because JSF had none. With EA4 JSF got its own navigation capabilities and now (at 1.0) is completely self sufficient. There is no need to use the Struts integration.
Some time ago during the JSF book promo (over at the JSP discussion) we talked extensively about this topic.
Currently I'd only recommend using the two together if you have a legacy Struts app and need to put some JSF components on the front end.

TTFN,<br /> <br />-bd-<br /> <br /><a href="" target="_blank" rel="nofollow">Jakarta Pitfalls</a> | <a href="" target="_blank" rel="nofollow">J2EE AntiPatterns</a> | <a href="" target="_blank" rel="nofollow">Mastering JavaServer Faces</a> | <a href="" target="_blank" rel="nofollow">Blog</a> | <a href="" target="_blank" rel="nofollow">Eclipse Blog</a> | <a href="" target="_blank" rel="nofollow">Eclipse 3 Live</a>
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Talk about reviving an old thread. I'm looking for more comments on this subject. I currently have a lot invested in Struts. With those Struts apps, I plan on adding JSF but will continue using Struts at the core. I talked to Craig at JavaOne 2004 and I spoke to him saying that I really liked Struts, the devs on my team are very comfortable with it. I told him that after spending a small amount of time with JSF, I felt that I wanted Struts to stay at the center of our apps and use JSF for rapid development of screens and simple validation. He was definitely supportive of that philosophy. But I did neglect to ask what advantage would I gain by developing new applications in a pure JSF environment? If you have Struts experts in house, why go pure JSF? Why not use what helps you develop faster from JSF, and stick with what you have in Struts? I'm a rookie with JSF, so I'd like to hear if I am incorrect in my thoughts. Thanks for any input. I really appreciate it.
I agree. Here's the link:
subject: Why JSF and Struts together?
It's not a secret anymore!