• All attributes of response object in JSP are introduced in detail


    Interface: javax.servlet.http . httpservletresponse, its parent interface is servletresponse, and servletresponse now has only one httpservletresponse sub interface. The main reason is that the current J2EE Web programs mainly use HTTP protocol as the main communication protocol. Function of response object: 1. setHeader( String name , String value ) Set the value of the specified […]

  • Solution to the random code of JSP page


    Solution to the random code of JSP page JSP page JS: Encodeurcomponent should be used twiceencodeURIComponent(encodeURIComponent(userAccount)); java:String  userAccount = java.net.URLDecoder . decode (useraccount, “UTF-8”); / * exception needs to be handled*/ It is a personal remark for later use

  • JSP Web Counter implementation example


    Copy codeThe code is as follows: //Filter classpublic class EcondingFilter implements Filter { private String charset = null; private ServletContext context = null; private String path = “”; /** *Save data to a local file before destruction*/ public void destroy() { //Get the value of the property in servlecontextString nums = (String) context.getAttribute(“nums”); //Create write […]

  • Summary of three methods of inserting CSS style into JSP page


    1. Exterior style When styles need to be applied to many pages, external style sheets are ideal. In the case of external style sheets, you can change the appearance of the entire site by changing one file. Each page is linked to the style sheet using the < link > tag. < link > the […]

  • Introduction of code execution and loading sequence in JSP page


    1. Java is the code running on the server side, JSP is running in the servlet of the server, and JavaScript and HTML are running code on the browser side. So the order of loading and executing is java > JSP > JS. 2. Loading order of JS in JSP The JS code on the […]

  • Implementation of JSP to prevent cross domain data submission


    Copy codeThe code is as follows: //Argsisvalidfilter. Java filter code list:package com.hety.uitl; import java.io.IOException; import java.util.Enumeration; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class ArgsIsValidFilter implements Filter { private static Log log = LogFactory.getLog(ArgsIsValidFilter.class); public void destroy() { } @SuppressWarnings(“unchecked”) public […]

  • JSP Chinese display question mark problem solution


    Question: the Chinese that you want to output in JSP is displayed as “?” Solution: search JSP in eclipse windows preferences, and select Chinese in the encoding option. In this way, the new JSP file will support Chinese display. Modify the existing JSP file as follows: change all encoding methods to GB18030, as follows: Copy […]

  • Examples of mixed use of JSP and SQL statements


    If you don’t say much, just give me an exampleinsert Copy codeThe code is as follows: String sql=”insert into allorder values(‘” + orderid + “‘,’” + bookid +”‘,’” + amount + “‘,’” + username + “‘)”; int result=stmt.executeUpdate(sql); if(result==1) response.sendRedirect(“index.jsp”); else response.sendRedirect(“detail.jsp”); delete Copy codeThe code is as follows: String condition=”delete from allorder where id=’”+ […]

  • JSP to get the session from action, clear session and judge


    There are several methods for JSP to obtain the session value from action For example, I have a session (“sessionid”, “sessionvalue”) in my action 1、 Use the struts tag to get: < s: property value = “# session.sessionid / > 2、 <%= request.getSession.getAttribute (“sessionid”); > session is also one of the built-in objects request.getSession It’s […]

  • Method of uploading files without refreshing by JSP + ajax


    This paper introduces the method of uploading files without refreshing by JSP + Ajax. For your reference, the details are as follows: List page: selectaddress.jspJS page: Ajax_ edit.jsJSP processing page: editaddress.jspUpload tool class: UploadUtil.java Idea: because of the security problem, JavaScript can’t manipulate the file, so Ajax can’t upload the file dynamically, so I chose […]

  • Effective solution of JSP loading JS file does not work


    Directory structure: JSP importing jQuery files always does not work because: Copy codeThe code is as follows: <script type=”text/javascript” src=”js/jquery-1.4.2.min.js”></script> It cannot access the files in the / WEB-INF / directory, so you need to put the loaded JS file into the webapp directory. test.html: Copy codeThe code is as follows: <%@ page language=”java” %> <%@ […]

  • Summary of calling java code in JSP


    There are two small exceptions to the intact delivery to the client: 1. If you want to pass <% or% >, because it is consistent with the special symbol of JSP, you must use the escape character to escape, < \% or% \ >2. If you want to pass comments and appear in JSP editing […]