包含标签:Java 的文章
-
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(); //将连接关闭 -
Jsp: setproperty: property value setting tag
< jsp: setproperty name = "bean instance name" {property = "*" | property = "propertyname" | property = "propertyna…… -
JSP Response. Containsheader() method: judge whether the HTTP file header with the specified name already exists
addIntHeader(String name,int value) Example <%=new Date()%> <% response.addheader("Refresh","1"); …… -
Implementation of Java multithreading
Inherit thread class public class Thread implements Runnable public class NewThreadName extends Thread { //New…… -
JSP PageContext. GetException () method: get the current exception object
getException() Example <%@page language="java" errorPage="error.jsp" pageEncoding="GBK"%> <% Integ…… -
JSP PageContext. Getsession () method: returns the current session object
getSession() Example <% HttpSession s = pageContext.getSession(); s.setAttribute("user","C语言中文网"); %&…… -
Java List. Iterator () method: iterates over the list elements
iterator() Typical application public static void main(String[] args){ List<String>list = new ArrayList&l…… -
JSP Page. Equals () method: compare two objects
equals(Object obj) Example <% boolean b = page.equals(page); out.print(b); %> -
Java Connection. Commit() method: commit the transaction
commit() Example Connection conn = …… //省略部分代码 conn.setAutoCommit(false); //先将事务设为手动提交 Statement…… -
JSP Request. Getheaders () method: returns all the values of the request header with the specified name
getHeaders(String name) Example <% Enumeration cts = request.getHeaders("accept-encoding"); while(cts.hasMo…… -
Java length() method: get the length of the string
length(); Example String strCom2="C语言中文网"; int length=strCom2.length(); Typical application Define the string …… -
JSP Request. Getdateheader () method: get the long value of the build date object
getDateHeader(String name) Example <% out.println(request.getDateHeader("Expires")); %> -
Other println methods for JSP out objects
public abstract void println(boolean b)throws IOException public abstract void println(char c)throws IOException publi…… -
Java substring() method: evaluate substring (intercept string)
Grammar 1 substring(int beginIndex) Example String strCom = "I Like Java"; String strResult = strCom.substring(3); …… -
JSP application. Getrealpath() method: get the real path of the virtual path
getRealPath(String path) Example <% String path=application.getRealPath("index.jsp"); out.println(path); %…… -
Java UDP communication: Java datagram socket class and datagram packet class
Datagram packet class Datagram socket class Example 1 public static void main(String[] args) { DatagramSocket ……