Hi, I've just been learning the basics of Struts, and am thinking of suggesting its use where I work - we currently use a couple of inhouse 'frameworks' for templating HTML and loading/saving from database but I think Struts might help simplify our JSPs. Before suggesting it I thought I'd try summarising how it works to make sure I understood, and also try it out to see what potential problems might be. Since I'd gone to the effort of summarising it, I thought I'd post it here for any comments on what I've got wrong, and hopefully to help other newbies. So heres my Quick Summary of Struts : Struts is a framework for the development of web applications using JSPs. A Servlet (class "org.apache.struts.action.ActionServlet") is configured in web.xml, with parameters specifying things like where the struts XML config file is. Also in web.xml this servlet is normally mapped to URL "/do/*". JSPs are written using custom tags provided by Struts (obviously standard JSP code will work to, but the tatg help simplify the JSPs). Forms in JSPs map to Struts actions. For each action (e.g. login, create user, submit score , etc. ) an Action class needs to be created extending "org.apache.struts.action.Action" and implementing the following function:
Also for each action a form class is created by extending ActionForm, this is a bean with getters and setters corresponding to the fields in the form on the JSP and a validate function which provides oportunity to check for missing fields, or format of data entered etc. Signature of validate method:
Properties file will quickly get very big and unmanageable.
Language selection using properties file :- Ideally I'd like to make language selection dynamically by user, not by swapping properties files. Perhaps I'm missing something.
Yet another thing for developers to have to learn - not sure about this, its probably easier to learn Struts than work on a JSPs which submit to them selves with loads of Java scriptlets
Its too generic/complex/heavyweight - notice a few posts suggesting this, but again, not sure that I agree
OK - Thats it any comments welcome! [ March 25, 2004: Message edited by: Mikey Warren ]
Seems like you've got a good handle on it. Couple of comments: while I have seen struts urls mapped with "/do/*", I think "*.do" is more common (Ted Husted says this in his book "Struts in Action"). Also, regarding language support, I'm not sure what exactly you mean by "swapping out" properties files but you can provide as many properties files as languages you want to support. They can all exist at the same time. You or your user simply need to specify the locale to use and Java will take care of the rest. Generic/complex/heavyweight? Well, I'd much rather have the plumbing already done for me than do it all over myself and still come up with something very similar yet less robust and feature-ladden.
Thanks for the reply. I was hoping that changing languages didn't mean just replacing the properties file with one for a different language - think I need to do a bit more reading up on that subject. Think I agree with you on the advantages of Struts, I was just interested in peoples opinions. It certainly seems preferable to what we've currently got which is JSPs with lots of Java code handling submits and presentation of data.