开发者

java servlet problems [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_如何学Go

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 6 years ago.

Improve this question

I just wonder why does only one copy of a servlet get created. And if a brower requests a servlet for the first time. How does servlet deal with that. I know java will compile code before running it. How about servlet? Last, How is information stored in a session object? I am new to java servlet, please help me. Thanks!


  • one servlet instance is created, because no more are needed. Each request is passed through the service(..) method in a separate thread
  • servlets are already compiled when starting the server - they are .class files
  • there is a <load-on-startup> configuration that lets you specify when should the container instantiate the servlet
  • session is identified by a session cookie, which is sent with each request. When a client sends the session id, it is looked up in a table and the appropriate Session object is returned.


Yes only one instance of servlet created for the first time when user hit URL that is mapped to it. and stays into the memory until its unloaded by classloader.

each request served in separate thread .

Session is a scope , each user has associated session id , generally it is mapped from the cookie from the request header and server identifies that this user is coming from this session


See Also

  • java-servlet-instantiation-and-session-variables
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜