A detailed explanation of the use of application in JSP programming

Source: Internet
Author: User
Tags functions relative

JSP call Javeabean command Usebean has scope settings, generally have application session page, and so on, page is the Usebean of each page to recreate the JavaBean new objects, the general situation is this, If you are sharing data between multiple JSP programs, you can use the session

and application meaning, the JavaBean will always exist, and the session relative to the user, application is relative to the application, in general, a user has a session, and as the user left and disappeared , and application is always there, like a servlet program, like the entire system of "global variables", and only one instance.

Control functions in MVC

So application this feature, is suitable to do MVC control function, the general MVC is used to do control functions, V is the basic JSP page, M is the middleware JavaBean and so on.

But with the improvement of JSP functions and promotion, and gradually replace the servlet trend, we in practice more use is JSP, sometimes in order to save trouble things, use JSP instead of servlet. especially its control function.

In fact, this control function is encapsulated in a JavaBean, JSP uses Scope=application to invoke this javabean, so that the JavaBean with control function is similar to the servlet resident memory, and interacts with various middleware in the background.

"Home" of the show

In practical applications, we often have multiple users to visit a page at the same time, such as the homepage, the home page has a lot of functions to run, such as directory classification, home program to read from the database tree data and expand, output to the home page, this function is encapsulated in the JavaBean.

Then home JSP call this JavaBean, use the scope=application, and then through the tree-shaped data buffer algorithm, so that many users at the same time to visit the home page, JSP will not need to start every time JavaBean and then repeatedly read the database. Undoubtedly greatly improve the speed.

So if your homepage JSP traffic is very high, then you should spend more time in this area optimization.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.