May 08, 2021 JSON
The specific process of receiving JSON data must be packets: commons-langs, commons-beanutils, etc., otherwise JSONObject is wrong and cannot be received.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="net.sf.json.*" %>
<%
BufferedReader in=request.getReader();
StringBuffer jsonStr=new StringBuffer();
String str="";
while((str=in.readLine())!=null){
jsonStr.append(str);
}
JSONObject jsonObj= JSONObject.fromObject(jsonStr.toString());
String name= jsonObj.getString("userName");
String pwd= jsonObj.getString("passWord");
String msg="";
if(name.equals("Tom")){
msg="登录成功";
}else
{
msg="登录失败";
}
response.getWriter().write(msg);
%>
A specific procedure for receiving JSON data.
JSP (Java Server Pages) is a dynamic web technology standard that Sun Microsystems has championed and many companies have worked with. J
SP technology is a bit like ASP technology, it is in the traditional web HTML file (*.htm, x .html) inserted Java program segments (Scriptlet) and JSP tag (tag), thus forming the JSP file (*.jsp). W
eb applications developed with JSP are cross-platform and can run both under Linux and on other operating systems.
(1) Write once and run everywhere. T
he code does not need to be changed except for the system.
(2) Multi-platform support for the system. I
t can be developed in any environment on all platforms, deployed in any environment, and scaled in any environment. T
he ASP.NET of JSP over the limitations of the system is obvious.
(3) Powerful scalability. F
rom running Servlet/JSP with just one small Jar file, to clustering and load balancing with multiple servers, to transaction processing, messaging, one server to countless servers, Java shows great vitality.
(4) Diversified and powerful development tool support. M
uch like ASP, Java already has many very good development tools, many of which are available for free, and many of which are already running smoothly across multiple platforms.
(5) Support server-side components. W
eb applications require powerful server-side components to support them, and developers need to use other tools to design components that enable complex functionality for web page calls to enhance system performance.
JSPs can use proven JAVA BEANS components for complex business functions.
(1) Like ASPs, some of Java's strengths are the problem. I
t is precisely for cross-platform functionality, for extreme scalability, so greatly increased the complexity of the product.
(2) Java runs at a rate of class-resident memory, so in some cases it does use a "minimum performance-price ratio" compared to the number of users.
On the other hand, it also requires hard disk space to store a series .java files and .class files, as well as corresponding version files.