你弄错了虚拟机和web容器的概念,你的测试程序是在虚拟机下运行的,不存在SERVLET容器,也不会自动执行init(),更不存在ServletContext了,你应该在将你的SERVLET布署在WEB容器里测试。
解决方案 »
- 我想用jsp做一个音乐播放器,如何添加播放列表的功能
- Struts中request.setAttibute在前台JSP文件中如何调用其值
- 找熟悉structs 2.0的朋友帮忙写书-兼职
- 查询要实现打包发包
- iReport求助
- 帮忙看看什么错误,java.lang.ClassCastException
- 求助!!编译的时候出现这个问题`希望高手指点
- jsp取access中的备注字段,如何才能保持和access中格式一致?
- 初学者数据库连接的问题
- TOMCAT 7 + JRE 1.6.45系统运行着突然停止
- 请教: 如何在一个javaBean中使用 jsp中的数据库连接?
- 奇怪的session使用问题?
|
+--javax.servlet.GenericServletpublic void init(ServletConfig config)
throws ServletException
Called by the servlet container to indicate to a servlet that the servlet is being placed into service. See Servlet.init(javax.servlet.ServletConfig).
This implementation stores the ServletConfig object it receives from the servlet container for later use. When overriding this form of the method, call super.init(config).Specified by:
init in interface Servlet
Parameters:
config - the ServletConfig object that contains configutation information for this servletjavax.servlet
Interface ServletConfig
getServletContext
public ServletContext getServletContext()
Returns a reference to the ServletContext in which the caller is executing.