1. CGI Evnironment Variable: request.getXxx..
2. get initiial parameter: ServlietConfig.getInitParameter(para_name);//parameter in web.xml
3. init() is guaranteed to be called and completed before the servlet handles its first request: when the server starts, when the servlet is first requested but before the service() is invoked, when at the request of the server administrator
4. in the destroy() method, a servlet should free any resources it has acquired that will not be garbage collected. and it also gives a servlet a chance to write out its unsaved cached information or any persistent information that should be read during the next call to init(). If the server crashed, destroy() may not work.
5. getParameter(..): get request parameters as part of its query string(GET) or as encoded POST data. (and there is getParameterValues(..) for the parameter which has more than 1 value. (Begin with Servlet API 2.2, you can use same parameter in query string and POST valus, then use getParameterValues(..).
6. getRequestURL, getRequestURI and so on
本文详细介绍了Servlet的生命周期,包括初始化、服务请求处理以及销毁阶段,并重点讲解了在各阶段如何通过不同方法获取配置参数与请求参数。同时,还探讨了在Servlet中处理GET和POST请求参数的具体方式。

被折叠的 条评论
为什么被折叠?



