Hi I'm using Struts 1.2.9 with Tomcat 6.0.18 and Netbeans 6.5 and it freezes every time I forward to the same controller path but with a different parameter.
I'm using EventDispatchAction.
I got an update() method and a list() method.
The update() method forwards to post?list ( which uses list() ). Everytime it forwards there it gets stuck up. I'm wondering why or is there a solution to this? Any help woudl be greatly appreciated! Thanks in advance!
If you're getting a stack overflow then you're stuck in a recursive forward or something--I'd take a very close look at the flow logic, because something is almost certainly wrong.
IMO it's not a good idea to mix JSP and action URLs in the same application; most people *probably* agree with that, but I could be wrong. There's nothing *technically* wrong with it, but it could create more confusion than its worth, and if that page ever *does* end up having to be an action (like for data preparation or something) you'll have to change everything that refers to it, and anybody that had it bookmarked will be out of luck.
Joined: Dec 11, 2007
An edit to the code above (I changed it anyway): should be:
I tried debugging it and it goes on a loop (weird!) at lines 83-86 above:
I'm really tempted to create a separate PostsListAction class but I want to see and learn most importantly if this problem can be solved and why is it this way. I still don't get it
About the creating a createPost.jsp (a page with from to create posts), how would you suggest I solve it? Should I add a new create() method that forwards to createPost.jsp and then the jsp's action is pointed at the add() method (http://mysite/post?add) ?
If nothing else I'd try making the parameter "complete", like "?list=list" or something like that--or check what the form submits to see the parameter value for the event.
I'm still pretty sure you don't want to forward to that request--if the page is refreshed the form will be submitted again. Search the web for the post-redirect-get pattern to see what I'm talking about.
Joined: Dec 11, 2007
Yeeeehaawww! "?list=list" worked!! I wonder why do I need to set the forward that way?
Ok, I'll research about the post-redirect-get pattern pattern. Are there any more patterns that I should be aware of?
I appreciate your effort David in helping me. Thanks a lot man, I've also learned some things
I'd guess that without a value, a parameter might be ignored.
There are a million patterns to be aware of ;) Fortunately only a few of them are genuinely useful. *Un*fortunately which ones are useful depend on what we're doing--the trick is to recognize when they can be used to good effect.