In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what the potential dangers of Servlet and JSP are, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Life cycle of 1.Servlet
The Web container is responsible for the life cycle of Servlet. When the client requests Servlet for * times, the container is responsible for initializing the Servlet, that is, instantiating the Servlet class. In the future, this instance will be responsible for the client's request, and generally will not instantiate other Servlet classes, that is, multiple threads are using this instance. The reason why Servlet is more efficient than CGI is that Servlet is multithreaded. If the Servlet is declared as a single-threaded model, the container will maintain an instance pool, and there will be multiple instances.
Thread Safety of 2.Servlet and JSP
The Servlet specification has stated that Servlet is not thread-safe, so keep this issue in mind when developing Servlet. Here is a realistic model to illustrate the problem, first define a Servlet class, and then define a SmulateMultiThread class and WebContainer class.
Importjavax.servlet.http.HttpServlet
Importjavax.servlet.ServletException
Importjavax.servlet.http.HttpServletRequest
Importjavax.servlet.http.HttpServletResponse
Importjava.io.IOException
/ / this class simulates multithreaded Servlet
PublicclassSmulateMultiThreadimplementsRunnable {
PublicSmulateMultiThread () {
}
Publicstaticvoidmain (String [] args) {
/ / process 100 requests
For (inti=0;i
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.