This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
This wouldn't necessarily be struts-specific, but all you need to do is identify the user in the action that is executed prior to your jsp display. In your jsp, you can use <logic:equal> and <logic:notEqual> tags to figure out what type your user is in order to display your form fields. You can do this much cleaner with JSTL tags, but I don't know them well enough to provide a code sample. Here it is with struts tags:
It really depends on how "production level" your code is going to be, and what you'll be doing with it from there. I would suggest a tiles based solution that loads an independent template and then you can load tiles in and out of the page depending upon your view.
Think of Tiles as a "controller" for your view layer, with the individual tiles and templates controlled by your definitions. Your Actions then call definitions only, and you can then fully encapulate your application and really lower the amount of duplicated code, so anytime you change something once, it changes it everywhere.
There's always a trade off. Sometimes it's the speed of development, sometimes it's in maintenance, sometimes it's just philosophy. I don't like to have logic on my page that says "well, show this, unless something here is happening, or something here, or....". You end up getting into some maintenance issues....
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