Java
-
JSP PageContext. Getpage () method: returns the current page object
getPage() Example <% page = pageContext.getPage(); %> -
JSP Request. Getrequesturl () method: get the absolute path of the client accessing the website
getRequestURI() Example <% StringBuffer p = request.getRequestURL(); out.println("访问的URL路径为:"+p); %&…… -
Java Connection. Setautocommit() method: sets the commit mode of the database connection
setAutoCommit(Boolean autoCommit) Example Connection conn = …… //省略部分代码 conn.setAutoCommit(false); -
JSP Response. Adddateheader() method: add the date header information of the corresponding name
addDateHeader(String name,long date) Example <% long date = System.currentTimeMillis(); response.addDateHea…… -
JSP Exception. Fillinstacktrace() method: populates the exception stack trace
fillInStackTrace() Example <%@page language="java" pageEncoding="GBK" errorPage="error.jsp"%> <% I…… -
Java Set. Contains() method: judge whether the set set contains the specified object
contains(Object o) Typical application public static void main(String[] args){ Set set = new HashSet(); se…… -
JSP Request. Getheader () method: get the file header defined by HTTP protocol
getHeader(String name) Example <% String ct = request.getHeader("content-type"); out.println("Content-type=…… -
Java DriverManager. Getdrivers() method: get all loaded drivers
getDrivers() Typical application public static void main(String[] args){ try{ Class.forName("com.microsoft.s…… -
Inheritance of Java classes: simple inheritance of Java and the difference between single inheritance and multi inheritance
Simple inheritance class class_name extends extend_class { //类的主体 } public class Student extends Person…… -
Java DriverManager. Getdriver () method: select an appropriate driver
getDriver(String url) Example Class.forName("com.MysqL.jdbc.Driver"); //注册MysqL驱动 String url = "jdbc:MysqL://l…… -
Java InetAddress class and its common methods
Example 1 public static void main(String[] args) { try { InetAddress ia1=InetAddress.getB…… -
Java Set. Toarray() method: create an array with all the objects in the set collection
Grammar 1 toArray() Example public static void main(String[] args){ Set set = new HashSet(); //定义Set集合对象…… -
Java Set. Add() method: adds an object to the set collection
add(E e) Example public static void main(String[] args){ Set set = new HashSet(); //定义Set集合对象 set.a…… -
JSP Response. Getlastaccessedtime() method: get the last access time of the session
getLastAccessedTime() Example <% long timeNum = session.getLastAccessedTime(); Date date = new Date(timeNum…… -
Solutions to Java non thread safety problems
package ch14; public class LoginCheck { private static String username; private static String password;…… -
JSP Request. Getcookies() method: get cookie object
getCookies() Example <% Cookie[] cookies = request.getCookies(); out.println("客户端包含"+cookies.length+"…… -
Java ResultSet. GetString () method: get the data of string type
Grammar 1 getString(int columnIndex) Example Connection conn = …… //省略部分代码 String sql = "SELECT username,pwd…… -
JSP Exception. GetMessage () method: get exception message text
getMessage() Example Typical application -
JSP config. Getinitparameternames() method: get the names of all initial parameters
getInitParameterNames() Example <% Enumeration names = config.getInitParameterNames(); while(names.hasMoreE…… -
What kind of programming language is Java?
Java is a simple, object-oriented, interpretive, robust, safe, naturally structured, portable, high-performance, multi…… -
Java replace() method: string replacement
Grammar 1 replace(char oldChar,char newChar); Example String str = "C语言中文网"; str = str.replace("C语言中文网","…… -
JSP Request. Getrequestedsessionid() method: get the session ID value of the website visited by the client
getRequestedSessionId() Example <% out.println(request.getRequestedSessionId()); %> -
JSP Response. Setheader() method: set header information
setHeader(String name,value) Example <% out.println(new Date()); response.setHeader("Refresh","1"); %> …… -
JSP Page. GetClass () method: get the page object
getClass() Example <% out.println("当前JSP页面的类是:"+page.getClass()); %> -
Java Connection. Createstatement () method: create a statement object
Grammar 1 createStatement() Example Connection conn = …… //省略部分代码 Statement st = conn.createStatement(); Gram…… -
JSP Request. Isrequestedsessionidfromcookie() method: judge whether the session ID is obtained from the cookie
isRequestedSessionIdFromCookie() Example <% out.println("from cookie"+request.isRequestedSessionIdFromCookie()…… -
Priority and execution order of Java threads
Priority overview public final void setPriority(int newPriority); public final int getPriority(); Use priority Exa…… -
Java Statement. Addbath() method: add batch statement
addBatch(String sql) Typical application public void bathInsert(){ Connection conn=getCon(); //省略部分代码 …… -
JSP application. Log() method: write information to the log file of the servlet
Syntax 1: log(String msg) Example <% application.log("specified message"); %> Grammar 2 log(String message…… -
Java format() method: format string
Grammar 1 format(String format,Object……args) Example String str = String.format("%d",400/2); String str2 = String.f…… -
JSP application. Removeattribute() method: removes the specified attribute
removeAttribute(String name) Example <% application.setAttribute("user","lzw"); application.removeAttribute…… -
Java Connection. Close() method: close the connection object
close() Example Connection conn = …… //省略部分代码 conn.close(); //将连接关闭