Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the key points of delivery technology in JSP Servlet

Shulou Source: shulou.com Published: 2022-06-02 12:30:08 11月04日 Update

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!

Tags: Location instance variable scope technology essentials difference parameter article validity code content customer statement application same not much that is to say most Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB Shulou Information Huawei vpn