一个讨论j2ee技术以及畅谈程序人生的地方,一个有共同兴趣和
龙心客栈 · dragonet · 2004-10-10
一个讨论j2ee技术以及畅谈程序人生的地方,一个有共同兴趣和爱好的朋友相聚的乐园。
|
首页
|
pooly design on Swing & design pattern>>>
What method does the container calls when instantiating servlet
时间: 2004-10-10
Posted By:
madhu sudan
on October 09, 2004 @ 08:12 AM in response to
Message #142094
1 replies in this thread
This is what i have understood from the Spec and some reading about Servlets,
Step 1.
Container reads the Deployment descriptor and read the servlets class name element value
say for example:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.mycompany.MyServlet</servlet-class> <!-- This value will be read.
<init-param>
<param-name>myVariable</param-name>
<param-value>1</param-value>
</init-param>
</servlet>
Step 2:
The container loads the class
Class clazz = Class.forName("com.mycompany.MyServlet");
Step 3:
Creates an Instance of the Servelt class,
Servlet objServlet = clazz.newInstance();
The above step will invoke the default contstructor (Zero parameter constructor of the servelt class. The spec dictates that Servlet Code should have a constructor with zero paremeter i.e default constructor).
Step 4:
The container then reads the initialization parameter "init-param" xml tags, and constructs a ServletConfig object and inovkes the
objServlet.init(config)
After which the servlet will be move the serviciable state from there on the Servlet instance is ready to service any request from the client.
Hope i could make some sense and clear your doubts.
Peace,
Madhusudan M Krishnamurthy
dragonet
引用(Trackback0)
评论
发表评论
最后更新
pooly design on Swing & design pattern
an article for thought about Swing
What method does the container calls when instantiating servlet
log4j synthetically
How to estimate
a trick about 'How to update multiple value in collection' on Struts
How to visit those methods which are not public?
学习java
八卦1: 瑜珈
Analysis Mechanism
原始快照:web.archive.org