JDBCSupport - An easy to use, light-weight JDBC framework -
Eduardo Bueno wrote:Right now my application is implemented like that, but I'm not sure if I'm in the right track.
Also, I want to know how to "remove" the command from the URI when doing a forward like above.
Eduardo Bueno wrote: Should I use forward command along with my page's URI, like this:
Eduardo Bueno wrote:Also, I want to know how to "remove" the command from the URI when doing a forward like above.
Bear Bibeault wrote:
Whether to forward or redirect depends on whether the command that was executed is idempotent or not. For example, you don;t want to forward after a delete operation because hitting the refresh button will re-execute the delete command.
Take a look at this article paying particular attention to the PRG pattern explanation.
Also, I want to know how to "remove" the command from the URI when doing a forward like above.
You don't. Whatever the most recent URI that was sent by the browser is what will appear in the address bar. Trying to change it is useless. Rather, adhere to PRG as described in the article so that there are never any hanging time bombs in the displayed URI.
I am also using Spring and I have never faced this problem. You can bind command to your controller i.e. your request.My conclusion is that using request.getServletPath() to discern between commands is not a good approach. So, does anyone have a good recommendation?
Note that I didn't use any redirect here, since there is no state change, just data fetching.
My problem is now when the JSP has already shown the data to the user: any submit that is done will again execute the login command, because the URI is set to "MyProject/Login.do".
Bear Bibeault wrote:If Login.do will re-execute an undesirable action, it should never be the end point of the request.
Eduardo Bueno wrote:So, should I redirect to Search.do (the home page) after my business logic in LoginCommand?
If I do this I will lose every request scope attribute that I need in SearchCommand.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |