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.