This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

What is the best way to get started with struts?

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done significant servlet/jsp based development work and have good understanding of "servlet container". However, I have not done "framework" such as "Struts" based web development. What would be best way to get started quickly? I am hoping to migrate traditional "web application" into "Struts" based application.


Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend "Struts in Action". If you read the first few chapters in it and "get" what is happening, you should be able to begin developing quickly.

Make sure that you understand what MVC2 "architecture" is.

Struts will "help" you implement good MVC2 practices, but it won't prevent you from creating Struts Applications that are incorrectly written. To get around this type of pitfall, here are a few of my recommendations...

WRT the JSP side of your code, you'll need to understand JSP tags and taglibs. You'll also need to make sure that your business logic isn't in your View Layer (JSPs), but safely encapsulated in your server-side. Your JSP's should only have information and code in it that is specifically related to your view.

When you create Actions, make sure that there is little or no business logic in them. Basically, they should be used to pass information from the View to your Model for processing and back, with the only logic in these classes based upon where to direct the response. If you encapsulate your business logic in this layer, you risk duplication of code at least, and if you should decide to abandon Struts for something else, you could end up rewriting thousands of lines of code to more all that business logic.

As far as your back end goes, it should be completely encapsulated and "not care" about the view. You should think along the lines of your business layer operating from a command line, Swing Client, JSPs, or any other view layer. If it is dependent upon a View technology, then you probably need to do more work.

Once you are at this point, you can begin your migration. I'm going to discuss this using the struts tag library in its 1.1 form (Since I don't know what servlet container you're running or what Java/JSP you are using, this is a safe bet. If you want to upgrade to Struts 1.2x you're more than welcome to as long as you're familiar enough with what's going on). I would recommend implementing:

All your links should be changed to actions registered in the Struts-config.xml file.

Wherever any URL references or sources are in your code, you should use the <html:rewrite/> tag or an appropriate tag that will utilize url rewriting and encoding.

Create Form beans and join them to your actions.

Create validations

Tile and template your application -- you may want to use JSP tiles at first and then move to the tiles-definitions.xml file at a future date, depending upon the size and complexity of the application you are migrating.

Finally, add Struts' validations.

By the time you reach this point, your migration will be 80-90% complete and you'll have a pretty good idea as to how to proceed from this point.
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can start to use struts framework at JavaRanch Journal articles.

and Apache Struts
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started learning struts with a book titled

Struts KICK START by James Turner and Kevin Bedell.
The book explains the framework quite well and provides a good grounding as well.

My suggestion is that once you have an understanding of the framework and its history(MVC) try and do as much examples as possible. I am still learning and improving day by day.

There is a good site out there that talks about struts and other more interesting stuff. Visit The Server Side.

Good Luck
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic