Ok, I understand that. But it still isn't clear as to why you would not call a JSP directly when all you are really doing is displaying a Form. There is no business logic yet. You can physically do anything you want of curse, but just keep in mind that if you are calling a jsp directly, then you are ditching MVC and defeating the purpose of using struts, as well as losing out on many of its benefits. Your user request is not going through your controller and you have now divulged underlying protions of your architecture to your users unecessarily. If you want to simply forward to a jsp, then in your struts-cnfig simply declare the "type" to be org.apache.struts.actions.ForwardAction. This leaves you with the benefits that struts provides, such as allowing that page to be mapped to a global forward (very convenient in many instances), keeping the user requests going through the ActionServlet, etc...
The only logic in this page is whether or not the user is logged in. Which technically is application logic, not something you would want to be controlling in the view. Now of course it seems very anal to try to strictly adhere to MVC like this, but these things are after all "best practices". Not to mention, you are now stating that in 100% of all cases, that view always requires that particular application logic be executed, as opposed to having your view be something that may potentially be forwarded to by multiple actions, where maybe that logic condition does not hold in all cases. It keeps the view a bit more generic.
But what you are saying is I should have another Action class that determines if I am logged in or not and then forwards either to AddReference.jsp or Login.jsp? Potentially. Let's say you always want to check that a user is logged in each time they submit a request. In such a case, you may want to have a base Action class containing this functionality which all your Actions will subclass. The template-method
pattern works good here. Here's an example:
Your base Action class:
An example of a specific Action class extending BaseAction:
So the idea being that your actions extend BaseAction if appropriate, and you simply write the run() method for each action. In that way, you can place all common functionality in the execute() method of your base Action class, and all the specific functionality in separate classes.
[ October 22, 2003: Message edited by: Jason Menard ]