aspose file tools*
The moose likes Struts and the fly likes What is the best way to get started with struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "What is the best way to get started with struts?" Watch "What is the best way to get started with struts?" New topic
Author

What is the best way to get started with struts?

Surendra Kashyap
Greenhorn

Joined: Jan 22, 2002
Posts: 6
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.

Thanks!

Surendra


-Surendra Kashyap<br />SCJP, SCJD, SCWCD, SCBCD and MCSE
Danilo Gurovich
author
Greenhorn

Joined: Aug 08, 2002
Posts: 7
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.


Danilo Gurovich<br />Manager, Web Development<br /> <br />dgurovich@lowermybills.com<br />2401 Colorado Ave., 2nd Floor <br />Santa Monica, CA 90404<br />(310) 998-6412
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
You can start to use struts framework at JavaRanch Journal articles.

http://www.javaranch.com/newsletter/Mar2002/newslettermar2002.jsp#struts
http://www.javaranch.com/newsletter/Mar2003/newslettermar2003.jsp#struts

and Apache Struts


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Bhavesh Ravjee
Greenhorn

Joined: Jun 15, 2004
Posts: 11
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


With great power comes great responsibility!
 
 
subject: What is the best way to get started with struts?
 
Similar Threads
need sugession for a good book
Why Struts?
JSF in Action: what experience level?
Book Promotion : Hacking Exposed: J2EE and Java
Best book for learning struts?