What are the built-in objects of JSP?
The built-in objects in JSP include: out application, request application, access customer data, response application, session application, application application, obtaining configuration objects in web.xml, obtaining exception information, etc.
JSP built-in objects are abstractions based on JSP functions. Any JSP page is included in output, request, response, context and exception handling. Next, I will introduce the built-in objects in JSP in detail in the article, which has certain reference value. I hope it will be helpful to everyone
[Recommended courses: JSP Tutorial】
1. out application
(1) Data is output to the client, providing the print() method and println() method
Example:
out.print("abc") out.println("abc")
(2) Buffer management, mainly cleaning, refreshing buffer and buffer size
Methods include: clear(), clearBuffer(), flush(), getBufferSize()
2. request application
(1) Get request parameters: send the form of hyperlink in the request, And add one at the end? To achieve
Example:
<a href="***? id=1">
The value of the ID can be accessed through the getParameter() method in the request object
(2)Chinese garbled characters
When accessed When the request parameters are garbled, you can use the following code to solve the problem
String user= new String (request.getParameter ("user").GetBytes ("ISO-8859-1"), "UTF-8")
When the access form parameters are garbled, you can use the following code to solve the problem
request.setCharacterEncoding ("UTF-8");
3. Access customer data
The client obtains available relevant information through the request object. Such as HTTP header, client mode, host address, port number, etc.
Methods: getHeader(), getMethod(), getProtocol(), getRemostHost(), getCookies()
4. Response application
(1) HTTP header information operation: set response type, disable cache, set automatic page jump, page refresh and timing
Disable cache:
response.setHeader("Cache-control","no-store") response.setDateHeader("Expires",0);
Auto refresh:
response.setHeader("refresh","10")
Timed jump:
response.setHeader("refresh","2;URL=login.jsp")
(2) Set the MIME type
Use the following code to output the content of the web page to the browser in different forms
response.setContentType (String type);
(3) Page reload Directing
Redirects a web page to another page using the response object provided by the sendRedirect() method. For redirection, the attribute in the request fails, and the beginning of the new request object
Example:
response.sendRedirect(String path)
5. Application of session
(1 )session life cycle
(2) Create and obtain the session
The session object can store or read customer-related information, and obtain the session object through the setAttribute() and getAttribute() methods
session.setAttribute(String name,Object obj); session.getAttribute(String name);
Note: getAttribute returns an Object type, you can enter coercion or toString() method
(3) Delete session
Implemented through session.removeAttribute(String name); method
(4) Setting up session within valid time
6, application application
(1) Life cycle
(2) Data operation
Attributes can be stored in the application object, read or delete the application method
setAttribute(): Store the attribute in the request
getAttributeName(): use the attribute Name
getAttribute(): Get the attribute value
removeAttribute(): Get the configuration object from the specified application object name
7. Get the configuration object in web.xml
The config object is mainly used to obtain server configuration information. You can obtain getServletConfig (Implementation) in pageContext.
Common methods:
getInitParameter( ): used to initialize parameters
getServletName(): access the Servlet server name
getServletContext( ) to obtain the Servlet context
8. Get exception information
Exception objects are mainly used to handle JSP file execution errors and exceptions. The main methods are:
getMessage(): Return an exception information string
getLocalizedmessage() returns localized errors
Summary: The above is the entire content of this article, I hope it will be helpful to everyone
The above is the detailed content of What are the built-in objects of JSP?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



jsp belongs to the backend. The essence of jsp is a servlet, and servlet is a server-side java application, so jsp is a back-end technology. JSP is deployed on the web server and can respond to requests sent by the client and dynamically generate web pages of HTML, XML or other format documents based on the request content, and then return them to the requester. JSP technology uses Java as a scripting language to provide services for user HTTP requests, and can handle complex business requirements together with other Java programs on the server.

After the new springboot project is created, the directory is as follows: Step 1: Add the jar package code required to configure jsp to the project's pom file: org.apache.tomcat.embedtomcat-embed-jasperprovided Step 2: Create a new directory webapp under the main path , create a new path WEB-INF under webapp, create a new path jsp under WEB-INF, and place the jsp file we want to use under this path. Step 3: Configure the access path and suffix code of the jsp file in the main configuration file: spring .mvc.view.prefix=/WEB-INF/jsp/sp

Implementation steps: 1. Introduce the JSTL tag library into the JSP page; 2. Obtain data from the database; 3. Paging the data; 4. Display the paging navigation bar in the page; 5. Display the number according to the current page number and each page. , just get the corresponding data from the paging data and display it on the page.

The difference between jsp and html: 1. Operating mechanism; 2. Purpose; 3. Relationship with Java; 4. Function; 5. Relationship with back-end; 6. Speed; 7. Maintainability and scalability; 8. Learning and use Difficulty; 9. File suffixes and identification tools; 10. Community and support; 11. Security. Detailed introduction: 1. Operating mechanism. HTML is a markup language, mainly used to describe and define the content of web pages. It runs on the client and is interpreted and executed by the browser. JSP is a dynamic web page technology that runs on the server side, etc. wait.

Master PHP built-in objects: Learn the operation and usage of commonly used built-in objects. Specific code examples are required. As a widely used back-end development language, PHP provides many powerful built-in objects that can help us develop and manage websites efficiently. Mastering the operation and usage of these built-in objects is crucial for PHP developers. This article will introduce some commonly used PHP built-in objects and provide specific code examples. 1. String processing object (String) String processing is often used in Web development, PHP

JSP is a dynamic web technology standard. Its file format is to insert Java program segments (Scriptlet) and JSP tags (tags) into traditional web page HTML files (.htm, .html) to form JSP files (*.jsp ).

1. The core sql statement to implement paging query (1) The sql statement to query the total number of records in the database: selectcount(*)from+(table name); (2) The sql statement to query the number of records for each query: where: 0 is searched Index, 2 is the number of items searched each time. select*from table name limit0,2; 2. Code implementation* I wrote these two classes in the previous article, DBconnection class: used to obtain database connections, Author object class. Click on the link to view the code for these two classes. Click the link to view the DBconnection class and Author object class (1) Login page: index.jsp. Inserttitlehere user column

Vue's built-in objects include Vue, Vue instance, data, el, options, parent, root, children, slots, scopedSlots, refs, isServer, attrs and listeners. Vue.js is a progressive JavaScript framework for building user interfaces. In Vue.js, there are some built-in objects or global APIs that can be used to create and manage Vue applications.
