What's the difference between doGet()/doPost() and processRequest()?
来源:互联网 发布:掌趣科技 涵凌网络 编辑:程序博客网 时间:2024/04/30 02:02
It's just a matter of moving common code to one place
*Note: doPost() and doGet() are part of the Servlet interface, and processRequest() is just a frequently used name for a helper method and is not part of any interface
Should you use processRequest()?
It depends how your Servlet is supposed to behave and how your servlet is invoked, if you want to have different behavior on POST requests than on GET requests, then implement them separately. If your servlet should have the same behavior whether a GET or POST is invoked on it, then route them to the same processRequest() method.
In most cases (probably 90% of the time) yes, you can route doGet() and doPost() to a single processRequest() method.
An example of where you would NOT want to route both to a processRequest() method is if you want to upload a file for POST requests and view some data for a GET request.
Is processRequest() considered good practice?
If GET and POST are doing the same thing, then yes absolutely. In fact, Arun Gupta (one of the main spec leads for Java EE) uses this pattern in his samples.
- What's the difference between doGet()/doPost() and processRequest()?
- What's the difference between an event and a delegate?
- what's the difference between OnDraw and OnPaint
- What's the difference between stack and heap?
- What's the difference between LastWriteTime and ChangeTime in FILE_BASIC_INFO?
- What's the difference between Heap and Stack
- What's the difference between overload and override
- What's the difference between glibc and libc6?
- What's the difference between "but" and "yet"
- What's+the+difference+between+virtualization+and+cloud+computing?
- What's the difference between parallel and concurrent?
- What's the difference between program arguments and VM arguments?
- What's the difference between Template and Table in Smartforms
- What's the difference between “local” and “my” in Perl
- what's the difference between int (* f [])(); and int f[]();
- What's the difference between gcc and g++/gcc-c++?
- What's the difference between headsets and headphones?
- What's the difference between HWND_TOP and HWND_TOPMOST?
- Java语言基础组成:关键字、标识符、注释、常量和变量、运算符、语句、函数、数组
- 前端工具装机整理
- Unity3d + NGUI 的多分辨率适配
- zigbee zstack ----- zmain_vdd_check();
- 实验吧—古典密码
- What's the difference between doGet()/doPost() and processRequest()?
- Servlet的默认processRequest方法
- 我在大学毕业后学习Linux系统的心得经验
- Vim常用功能总结
- 数据库SQL优化大总结之 百万级数据库优化方案
- 禁用CentOS下Apache的测试页面
- 虚拟主机
- 鸡年的几次面试
- request.getParameter() 和request.getAttribute() 区别