I would think that would work, as long as firstForm1 and firstForm2 are either the class you specified as the form class for the action or they are super classes of it. Also, capitalizing your class names, and camel casing your object names may make your code a little easier to read.
Joined: Jan 08, 2010
can you please explain with more detail using my example?
Joined: Aug 29, 2008
Well first off I made an assumption here, and maybe its an incorrect one, that you are always calling this action class using the same action. To tell you more I'd need to see your struts-config.xml entries for the actions that are going to go to this Action class, what classes you are using for the form beans for each action, and how those form beans fit into your class hierarchy with firstForm1 and firstForm2.
Always, better to use instanceof in your conditions
This can be achieved if you have same action class mapped with different action paths and you submit different forms accordingly from several JSPs
i.e. Say you have configured Action1 in struts-config with Form1 (used in JSP1), Form2 (used in JSP2), Form3 (used in JSP3). If you are submitting form JSP1 then you would get the instance of Form1 in the Action1's method. Similarly JSP 2 & 3
I prefer not to have such scenarios since for developing it may be easier but for maintenance?? Never
Have Fun with Java
little,little.. little by little makes a lot..