File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSF, JSTL, Struts, Velocity - where the heck do I start? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSF, JSTL, Struts, Velocity - where the heck do I start?" Watch "JSF, JSTL, Struts, Velocity - where the heck do I start?" New topic
Author

JSF, JSTL, Struts, Velocity - where the heck do I start?

Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
OK, even though the subject sounds like it, I'm not a complete newbie to java web apps. I've done some work in servlets, and used jstl for an app.

But, it's been just me dabbling in my 'free' time. In the next year or so, we will be making a major push in web-based java programming. So we need an official strategy or direction.

I'm tempted to stick with the basic jsp-servlet-bean architecture and ignore the others, but I'm concerned we could be missing out on some major productivity improvements.

So my question for the experienced web developers is - If you could start new with a web-based architecture, what would it be and why?

Thanks for your time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61419
    
  67

Hoo boy, talk about inviting varied opinions...

For myself, I'm not a big fan of the existing popular frameworks (though I haven't had a chance to look into JSF enough to have a valid opinion). That said, I am most certainly a big fan of the architecture they impose -- namely, the "Model 2" approximation of the MVC pattern. So whichever way you choose to go, either take the time to make sure your app(s) will adhere to the Model 2 pattern, or use one of the frameworks that imposes it. (Personally, I've developed a light-weight Model 2 framework that does exactly what I need).

JSTL is a must. Striving to eliminate Java scriplets and scriplet expressions completely from the JSPs is highly recommended. If you can, use a JSP 2.0 container so you can leverage the power of the EL, tag files, and the simplified custom tag API to help achieve scriptless pages.

There will be other opinions. Struts has lots of fans. I'm just not one of them. But in the end, whatever helps you create a well-structured application is the way you should go.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeffrey Hunter
Ranch Hand

Joined: Apr 16, 2004
Posts: 305
I was in a similar position about six months ago -- I had a firm grasp on Java, and a good idea of how to develop basic web apps, but not a very good vision of the overall picture.

Suffice it to say that my early web apps were horrendous -- JSP pages littered with Java code, little use of Servlets, and a near complete brush-off of the MVC architecture.

So, through much blood and sweat and bad code, I've refined my development process to follow the MVC architecture, and I'm on the path of rediscovery, so to speak.

What I've learned, through experience, and consultation with fellow Ranchers and other professionals, is this:

  • recite the mantra follow the MVC architecture -- by doing so, regardless of which components you use, you can develop a coherent, scalable product which is relatively easy to maintain
  • keep the Java code out of the JSP as much as possible (to do this, implement custom tags and the JSTL}
  • use Servlets to process user input, contact back-end database(s), process data, and redirect the user as necessary
  • JSP pages receive processed data and display it to the user (think of the Servlet as the butcher back behind that window in the supermarket, and the JSP as the shelves of pre-packaged meat you have to choose from out on the floor)
  • Struts is a framework which enforces a standard MVC architecture and may take some time to learn -- you can model your system to follow the MVC architecture without Struts, it's up to you
  • get up to speed on XML, since it's a must for configuring and customizing your web app

  • These are just some of the main points I've picked up. Good luck.
    Leandro Melo
    Ranch Hand

    Joined: Mar 27, 2004
    Posts: 401
    Hi everyone,
    this is really an important issue, so i'll give my opinions.

    First of all, using some frameworks doesn't mean you can't use other ones. Sometimes, a conjunction of them is very nice. You can use, for example, JSTL + Struts + Velocity + Tiles + ... actually, this is very usual. You can even use JSF with Struts (that's what i heard, and with a first view, i really think that is possible, it's probably not recomended).

    There are a few things though that you need to keep in mind, MVC for architecting and Design Patterns where needed.

    Following this, you have nowadays, two basic options:

  • Struts
  • JSF

  • Personally i think Struts is a great framework and the time you spent learning it will save a lot, lot, lot time of developing latter. It's worth!
    Modelling your app without Struts is possible of course, but it'll take more time and much more effort. Nevertheless, keep in mind that Struts won't do everything for you, it'll give you the basis, if you want, it's very simple to ruin the MVC helping of Struts.

    I don't know JSF, but it is sure a great techonology, altough it hasen't gotten so popular yet (everything needs some time), so the market is still in a lattence period. A lot of recognized professionals have gone in JSFs direction latelly.
    JSF also incoporates most ideais of Struts (maybe all of them) and a lot more (note that Craig McClanahan, the "inventor" of Struts is also one of the creators of JSF). From some pieces of code i've seen, JSF can give you a lot of productivity. JSF also comes from JCP, what is an important thing (Struts is not a JCP framework).

    Finally, it's a bet, take the "risk" with JSF (i don't really know if we say that this is actually a risk, as i said, a lot of people have gone to the directions of JSF), or go with the already stabilished and recognized technology, Struts.

    Another point to evaluate is how much time you have for developing, JSF seems to be quite complex compared to Struts.


    Leandro Melo
    SCJP 1.4, SCWCD 1.4
    Jeroen Wenting
    Ranch Hand

    Joined: Oct 12, 2000
    Posts: 5093
    Forget Velocity, at least for now.
    Forget Struts, it's an overblown overhyped overweight solution that's in most cases more trouble than it's worth.
    Forget JSF for now, it's still too much in motion and not quite stable yet (major changes have already been predicted for the next minor version for example).
    That's not to say Struts doesn't have some good ideas, but they overdid it in an attempt to have a perfect architecture and maximum flexibility. I've created a small framework that does all Struts does (insofar as I need it) tailormade for my application in maybe 2 days work, in Struts I'd still be struggling to get all the required components to work together properly and add megabytes of jars and xml files to an application that's itself maybe a hundred KB at most.

    JSTL is great. Flexible, powerful and easy to use.


    42
    Faisal Khan
    Ranch Hand

    Joined: Jun 29, 2003
    Posts: 285
    A very important topic indeed and I have been burnt and learnt the hard way, here is a brief of what I learnt. Pretty much what has been stated above but adding a couple of more details.

    My first real java webapp was a bunch of JSPs (lots of java code in them) and Java beans (with all data access methods in them).

    I re-architected this application with the help of many ranchers and this app was re-written to abide by the model 2 MVC compliant. I felt that in addition to getting the MVC part right, there is also extremely important to get the data acess right, I subscribed to the DAO design patter.

    Over all my app had ended up as following:

    1. MySQL db in the backend
    2. A DAO layer, which can easily be enhanced to support another RDMBS
    3. The business model, mostly java beans
    4. Struts to communicate between the user request and the business model - there are a number of alternatives one can use here.
    5. JSP and Tiles (I thought tiles was excellent) for the presentation - I used a JSP 2 container so good use of JSTL, EL and Tags - making things very maintainable.
    6. Good usage of filters (i think they are brilliant).

    In the end, I learnt that the actual tool or technology one uese is relatively less important than getting the actual architecture to be at a sound level.

    HTH

    FK


    The secret to creativity is knowing how to hide your sources.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: JSF, JSTL, Struts, Velocity - where the heck do I start?