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 are the technical points of delivery in JSP Servlet, 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!
Key points of JavaBean transfer Technology in JSP Servlet
First, initialize JavaBean
1. In JSP
The procedure in the previous paragraph of code is as follows:
◆ looks for the JavaBean of the same id according to the parameters of scope, and if it finds it, it jumps out of the
If ◆ does not find it, it creates an instance at the location of the scope parameter and executes the initialization statement in and
That is, if you are sure that you must set the beanname on the position of the scope parameter in the current state, avoid using code similar to the above, but should keep the statement outside.
2. In Servlet
Package.classname beanname=new package.classname (); then place the beanname in a different location
Second, the location and operation of JavaBean
The storage location of JavaBean here mainly refers to different scopeparameter, so it will be discussed separately here. JSP servlet read and write mode (Servlet only lists the reference to get or set, omitting the setXxx and getXxx of specific attributes)
JSP Servlet
◆ scope= "page" Request.pagecontext or direct reference
◆ scope= "request" Request package.classname beanref= (package.classname) request. GetAttribute ("beanname"); or request.setAttribute ("beanname", beanref)
◆ scope= "session" httpSession HttpSession session= request.getSession (true)
Package.classname beanref = (package.classname) session.getAttribute ("beanname"); or session.setAttribute ("beanname", beanref)
◆ scope= "applicaton" servletcontext package.classname beanref= getServletContext (). GetAttribute ("beanname"); or getServletContext () .setAttribute ("beanname", beanref)
III. Specific application
Type application
The default setting of ◆ scope= "page" in JSP is similar to a page-wide variable instance.
◆ scope= "request" is an instance of a variable within the valid scope of a request.
◆ scope= "session" variable instances within the scope of one client access, each access is different.
◆ scope= "applicaton" is a variable instance within the scope of the server program, similar to static, and is valid for every customer visit.
The above is all the contents of the article "what are the Technical points of delivery in JSP Servlet". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.