Session clearing and expiration
The Program actively clears session data.
Set session failure: session. invalidate ()
Remove an attribute from a session:
Syntax: public void removeAttribute (String name );
The server actively clears sessions that have not sent a request again for a long time.
Set session expiration time
Method 1: public void setMaxInactiveInterval (int interval); (unit: seconds)
Method 2:
30
(Unit: minute)
JDBC
Java DataBase Connectivity (Java DataBase Connectivity) allows Java programs to access various databases. It is composed of a group of classes and interfaces (JDBC APIs) Written in Java, they are located in java. SQL and javax. SQL.
Tomcat Data Source
Data sources are used to connect to databases, and connection pools are used to manage connection objects.
Steps for using data sources in Tomcat
1. Add the database driver file to the Tomcat/lib directory.
2. Configure conf/context. xml of Tomcat
3. Configure the web. xml file of the application (optional)
4. Use JNDI to obtain the connection object
JSP action tag
Through the action tag, the programmer can encapsulate the display function of the page in the JSP page to make the whole page more concise and easy to maintain.
Load a JavaBean that will be used in the JSP page to take advantage of the reuse of the JavaBean Component
Dynamically include the results of the contained page. First process and then include
<% @ Include %>
Static inclusion: includes the content of the contained page. Include before processing
Implement file upload in JSP
1. Check the request type
boolean isMultipart = ServletFileUpload.isMultipartContent(request);String fileUploadPath = session.getServletContext().getRealPath("/upload");2. Object Declaration
FileItemFactory factory = new DiskFileItemFactory();ServletFileUpload upload = new ServletFileUpload(factory);
3. Conversion request object
List
fileItems = upload.parseRequest(request);
4. Save the uploaded file
File saveFile = new File (fileUploadPath, fileName); // The directory does not exist if (! SaveFile. getParentFile (). exists () {// create the directory saveFile. getParentFile (). mkdirs ();} fileItem. write (saveFile );
Use CKEditor
First download CKEditor
Http://ckeditor.com/download
Decompress and copy CKEditor to the project.
Introduce CKEditor to the page:
1、<script type="text/javascript" src="ckeditor/ckeditor.js"/>
2. Add class = "ckeditor" to the textarea label"
After the introduction, you can use CKEditor to edit the content.
CKEditor folder
Lang: stores multi-language files
_ Samples: stores the official Demo
Skins: Skin folder
Large Field
Oracle versions earlier than 10 Gb have problems with big data processing.
The version after Oracle 10 Gb has solved the big field problem.
Paging Query
Paging advantages:
1. Clear and intuitive data
2. Unlimited data volume
3. The page is no longer lengthy
To query by page:
1. determine the number of data displayed on each page
2. calculate the total number of displayed data
3. Calculate the number of pages displayed = total number of pages/number of data displayed per page (+ 1)
4. Compile a paging query SQL statement
5. Implement paging Query
Java small script disadvantages:
1. Chaotic code structure and poor readability
2. error-prone compiling process
3. Difficult to maintain
EL features
1. Obtain attributes of the JavaBean object
2. Obtain elements of arrays, lists, and Map objects.
3. Simple processing of raw data using various operators
4. Shielding Common exceptions
5. Simple automatic type conversion
Tag
The syntax is as follows:
Value: the value to be displayed.
Default: default Value
EscapeXml: whether to escape
JSTL label Classification
Core label library http://java.sun.com/jsp/jstl/core c
International/formatted label library http://java.sun.com/jsp/jstl/fmt fmt
XML library http://java.sun.com/jsp/jstl/xml x
Database tag library http://java.sun.com/jsp/jstl/ SQL SQL
Function tag library http://java.sun.com/jsp/jstl/functions fn