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.
-Surendra Kashyap<br />SCJP, SCJD, SCWCD, SCBCD and MCSE
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.
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 />firstname.lastname@example.org<br />2401 Colorado Ave., 2nd Floor <br />Santa Monica, CA 90404<br />(310) 998-6412