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.
Joseph, my question is that does Struts provide a way as part of the framework to handle these two methods differently. I mean, in servlets, if it's a get request, automatically, the doGet() method gets called. Is such a thing possible in Struts also? Or do I have to programmatically check using request.getMethod() to have a separate logic in place for the two cases?
Joined: May 05, 2006
You have to check explicitly, from what I understand. One of Struts' features is that you don't have to worry if it was a GET or a POST. It rolls all of that into one execute method.
You can override doGet and doPost, but that will break the whole Struts framework stuff. Not recommended. I would just do an if on request.getMethod();