I'm programming a web application in Netbeans 8.0.2 and I'm currently working on setting up the Controller Servlet. I'm a student and I have a question regarding the doPost and doGet methods.
I know:
- URL patterns associated primarily with page requests are managed by the doGet method.
For example, /category, /viewCart, and /checkout result in the display of the category, cart, and checkout pages.)
- URL patterns associated with form submits and the transport of sensitive user data (e.g., /addToCart, /updateCart, and /purchase) are managed by the doPost method.
SO
According to that information, I was wondering where should I put these following actions: viewAccount and viewOrderHistory? To my knowledge they both contains data (customer's information) so I would put them under doPost.
But I'm confused because the action viewCart is under doGet... and according to the information I have, viewCart action will contain data once the customer added a product in their cart. So why is it under doGet instead of doPost?
Should I put every action that starts with "view" under doGet, regardless if they handle data or not?
Also, where should I put logout action? doPost or doGet?
I hope I have been cleared enough so you can understand me.
Thanks a lot!