In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the use of JSP, I believe that 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!
How it works:
When accessing a .jsp file, the server converts the .jsp text into a .java file (servlet), creates an instance of it, and calls its service () method to respond.
The constituent elements of a JSP web page are:
Comments (, instruction elements (), script elements (template data (static html tags)
), action elements (jsp:forward, etc.)
Or it consists of static Html page content and dynamic scripting language programs and JSP tags.
JSP script:
Program script, an is a local variable
Expression script
Declaration statement an is a global variable
JSP instruction elements and action elements
Instruction element:
Import the class library, which is executed at compile time by jsp
(static include)
Action element
Dynamic inclusion
Forward, jump
Example creation object
Note:
1) the difference between static inclusion and dynamic inclusion
2) the difference between forwarding and redirecting response.sendRedirect ()
The built-in objects of Jsp and their functions:
Request: indicates the request from the client, contains all the request information, and is the resquest parameter of the service (or doPost/doGet method) method in Servlet. Function and encapsulate the request from the client to the server
Response: processes the response generated by JSP and then sends the response result to the client. Is the response parameter of the service (or doPost/doGet method) method. Function: encapsulates the content sent by the server to the client
Out: represents the output stream and is sent to the client as a response to the request. Is an example of PrintWriter. Used to output content to the customer
Application: works for the entire application. Is an example of ServletContext. Different browsers share one data, and the server ends when the server is shut down. It's global. Function: a collection object used by the server to share data among different users, different browsers, and different pages under the same web application. Each dynamic page can store property variables to share among different pages and different users.
Session: indicates the session status of the user. With this mechanism, each user can be easily identified, and the session state of the user can be saved and tracked. Is an example of HttpSession. Ends when the browser is disconnected.
Function: create a collection object on the server side to share data between different requests of the same browser, and each dynamic page requested by the client can store or update the property variable and provide it to another dynamic page to access the variable.
Principle: each user will be assigned a unique ID number when creating a session, and it will be sent to the client at the same time. Every time the client accesses the server, the id will be passed to the server, and the server will locate the session of the client.
Forward. The difference between redirecting response.sendRedirect and:
Forwarding is transferred directly from the server to another page and returned to the client. The client does not know it, and it must be in the same website and cannot be placed directly in the script. It must be separated by {}. Redirection is to return to the client before there is a client request. You can put it directly in the script.
And the difference:
The process included when using the former is static, and static inclusion means that the included file will be inserted into the JSP file. Unlike instructions, the contents can be changed dynamically and are determined at the time of execution, while the contents of the former are fixed.
There is only one file for static inclusion results, and two files for dynamic inclusion results.
The main differences between JSP pages and Html pages are:
The former has server-side Java code, that is, JSP scripts or tags, while the latter has only static html tags and javascript code, which can only be executed on the client side.
The above is all the content of this article "what's the use of JSP?" 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.