viviallddn
anthonliu · 2004-11-23
SCWCD
2004-11-23
Tag:
Java
版权声明
:转载时请以超链接形式标明文章原始出处和作者信息及
本声明
http://anthonliu.blogbus.com/logs/511297.html
1.The GenericServlet class
implements the Servlet interface. It is an abstract class that provides implementation for all the methods except the service() method of the Servlet interface. It also adds a few methods to support logging. We can extend this class and implement the service() method to write any kind of servlet.
2.HTTP 1.0 requests
can have only one of the following three methods: GET, HEAD, or POST. HTTP 1.1 adds five more: PUT, OPTIONS, DELETE, TRACE, and CONNECT.
3.
A
PUT
request is used to add a resource to the server. It means, “put the data sent in the
message body and associate it with the given Request-URI.
4.
Clicking on a
hyperlink
always sends a GET request
5.
An
important point
to note about the getWriter() and getOutput-
Stream() methods is that you can call only one of them on an instance of ServletResponse.
6.<load-on-startup>
can tell the servlet container to load the servlet on startup. Not lazy loading.
7.RequestDispatcher.include(ServletRequest request,ServletResponse response)
This method passed request to the other resource temporarily,all changes to the headers or
status code of the request made by the other resource are
ignored.
8.
The difference between the getRequestDispatcher() method of ServletContext and that of ServletRequest: you can pass a relative
path to the getRequestDispatcher() method of ServletRequest but not
to the getRequestDispatcher() method of ServletContext.
9.
ServletContext attributes set on one JVM are not visible on another JVM.We must use the database or the session to share the information.
10.
A Servlet container is not required to propagate ServletContextEvents and ServletContextAttributeEvents to different JVMs. This means that changes to the ServletContext in one JVM may not trigger a method call on a ServletContextListener ServletContextAttributeListener
in another JVM.
11.
ServletContext initialization parameters are available in all of the JVMs.Recall that ServletContext initialization parameters are specified in the deployment descriptor.
12.
An HttpSession can reside on only one JVM at a time.
A servlet container is not required to propagate HttpSessionEvents to different JVMs.
Attributes of a session that implement the java.io.Serializable interface are migrated appropriately when the session migrates. This does not mean that if the attributes implement the readObject() and writeObject() methods, they will definitely be called.
A container notifies all of the session attributes that implement the HttpSessionActivationListener interface when it migrates the session.
A container may throw an IllegalArgumentException in the setAttribute() method of HttpSession if the attribute is not Serializable.
13.Handling exceptions thrown by RequestDispatcher
If the exception thrown by the included or forwarded resource is a Runtime-Exception, a ServletException, or an IOException, it is thrown as is by the include() or forward() method.
Otherwise, the exception is wrapped in a ServletException as the root-Cause, and the ServletException is thrown by the include() or
forward() method.(对于业务的异常是作为root-Cause被包在ServletException中,所以处理时要用Throwable t = se.getRootCause()提取。)
14.
HttpSessionListener 中的sessionDestoyed是在session invalidated之后才由容器call的所以此时session中的attribute已经被unbind.得不到可用的数据。因此,要想通过sessionDestoyed来控制用户登出后的数据库操作(比如通过userid更新数据库记录)是做不到的。唯一可行方法是使用HttpSessionBindingListener来作为 userid 的wrap。在session销毁之前把当前用户的id从session中移出,此时HttpSessionBindingListener中的valueUnbound被激发。
15.
There are two inconsistencies in the way the session-timeout tag of the deployment descriptor and the setMaxInactiveInterval() method of
HttpSession work:
1 The session-timeout value is specified in minutes, while the set-
MaxInactiveInterval() method accepts seconds.
2 A session-timeout value of 0 or less means that the session will never expire, while if we want to specify that a session will never expire using the setMaxInactiveInterval() method, a negative value (not 0) is required.
相关文章:
感恩节(Thanksgiving Day)
2004-11-26
java:comp/env
2004-11-26
ModelMBeanInfoBuilder
2004-11-20
对象构造顺序(basic knowledge)
2004-11-14
Java 基础补遗
2004-11-14
收藏到:
Del.icio.us
引用地址:
viviallddn
发表于
09:13
|
编辑
|
继续话题
|
转发
|
推荐
发表评论
原始快照:web.archive.org