1.关于ContentType
语法 Response.ContentType [= ContentType ]
ContentType 属性指定响应的 HTTP 内容类型。如果未指定 ContentType,默认为 text/HTML。
描述内容类型的字符串。该字符串通常被格式化为:类型/子类型,其中类型是常规内容范畴,而子类为特定内容类型。
参考http://baike.baidu.com/view/1547292.htm;
http://hi.baidu.com/swmonoku/blog/item/029863d1349105d4572c84d9.html;
2.关于session;
session,appication的创建和销毁都是通过servlet的listener完成的;
1)Listener 是Servlet的监听器,它可以监听客户端的请求、服务端的操作等。通过监听器,可以自动激发一些操作,比如监听在线的用户的数量。当增加一个 HttpSession时,就激发sessionCreated(HttpSessionEvent se)方法,这样就可以给在线人数加1。常用的监听接口有以下几个:
2)ServletContextAttributeListener监听对ServletContext属性的操作,比如增加、删除、修改属性。
3)ServletContextListener 监听ServletContext。当创建ServletContext时,激发contextInitialized (ServletContextEvent sce)方法;当销毁ServletContext时,激发contextDestroyed(ServletContextEvent sce)方法。
4)HttpSessionListener 监听HttpSession的操作。当创建一个Session时,激发session Created(HttpSessionEvent se)方法;当销毁一个Session时,激发sessionDestroyed (HttpSessionEvent se)方法。
5)HttpSessionAttributeListener 监听HttpSession中的属性的操作。当在Session增加一个属性时,激发attributeAdded (HttpSessionBindingEvent se) 方法;当在Session删除一个属性时,激发attributeRemoved(HttpSessionBindingEvent se)方法;当在Session属性被重新设置时,激发attributeReplaced(HttpSessionBindingEvent se) 方法。
参考http://hi.baidu.com/nickshen3/blog/item/aa8b4e23ca7461519822edd3.html;
http://hi.baidu.com/gongyh/blog/item/a0b5ce2a298c899c023bf63c.html
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20941140/viewspace-557974/ ,如需转载,请注明出处,否则将追究法律责任。