tag:blogger.com,1999:blog-13911304.post-1119915916791544602005-06-27T16:20:00.000-07:002005-06-27T16:49:27.690-07:00Playing with Struts Day 1<span style="font-size:85%;">Ok, so finally after looking at much examples, I thought I had a basic idea and this was too trivial to actually go about trying. But today out of sheer boredem, I exported the struts-blank.war into Tomcat and got hacking at it. So here goes my tryst with struts:<br /></span> <ul> <li><span style="font-size:85%;">2:15 PM Ok then, I edit struts-config.xml: create a simple logonForm extending DynActionForm, add action logon, map the action to logonForm and a LogonAction class, that I will code in a bit.</span></li> <li><span style="font-size:85%;">2:30 PM I create the jsps using the tags.</span></li> <li><span style="font-size:85%;">2:40 I get interrupted, they want me to do some work actually.</span></li> <li><span style="font-size:85%;">3:30 PM Ok where was I? Right the jsps; I write a simple action class: LogonAction, in which I check the username and password against hard-coded values and if they match, forward the page to success, if not forward to failure.</span></li> <li><span style="font-size:85%;">3:35 PM I am all compiled and ready to go, I fire up Tomcat and go to the logon page.</span></li> <li><span style="font-size:85%;">3:40PM Hurrah! I can actually see the logon page, I hit submit, the page goes to logon.do, but empty page.</span></li> <li><span style="font-size:85%;">3:45 PM I think there might be something wrong in the Action class, so I comment the very cryptic username, password checking logic and just forward the page to success. I fire up Tomcat again.</span></li> <li><span style="font-size:85%;">Fast Forward: a few iterations, debugs, logs and System.out.println later:</span></li> <li><span style="font-size:85%;">4:30 PM Still no luck, also anything I log or write to sysout does not show up in the logs, so probably the action calss is not even getting invoked.</span></li> <li><span style="font-size:85%;">4:45 PM I tear out my hair, google for "struts action empty page", there is something about previous Action API requiring you to implement perform and current ones needing you to implement execute.</span></li> <li><span style="font-size:85%;">5:00 PM So, sure enough I am impelmenting perform, I just change this to execute and try again, Hallelujah!, I am strutting away to glory.</span></li> </ul> <span style="font-size:85%;">Moral of the story when in "Action", "execute", do not "perform".<br />So much for struts.<br /></span>Java Foohttp://www.blogger.com/profile/14104080800348407575noreply@blogger.com