Home > Back-end >  The JSP file after the jump form the form submission is null
The JSP file after the jump form the form submission is null

Time:10-10

This is the form code
User name: & lt; Input type="text" name="username" value="" placeholder=" enter the user name "an onfocus=" showUserTip () ", "
Style="width: 150 px" maxlength="100" onblur="checkUser ()" & gt;



Compact & amp; Emsp; Code: & lt; Input type="password" name="passwd" value="" placeholder=" password "an onfocus=" showPwdTip () ", "
Style="width: 150 px" maxlength="100" onblur="checkPwd ()" & gt;



Mail & amp; Emsp; Box: & lt; Input type="text" name="email" value="" placeholder=" enter your
"Style="width: 150 px" maxlength="100" & gt;


Electrical & amp; Emsp; Words: & lt; Input type="text" name="phone" value="" placeholder=" input phone
"Style="width: 150 px" maxlength="100" & gt;











Below is new. The JSP file part of the code
<%
Request. SetCharacterEncoding (" utf-8 ");
String username=request. The getParameter (" username ");
System. The out. Println (" username===="+ username);
String passwd=request. The getParameter (" passwd ");
System. The out. Println (" passwd===="+ passwd);
The String email=request. The getParameter (" email ");
System. The out. Println (" email===="+ email);
String phone=request. The getParameter (" phone ");
System. The out. Println (" phone===="+ phone);
Try {
Request. SetCharacterEncoding (" utf-8 ");
Class.forName("com.mysql.cj.jdbc.Driver");//load database driven, registered with the driver manager
The String url="JDBC: mysql://localhost: 3306/user? UseSSL=false& ServerTimezone=UTC ";
String name2="root";//
String password="123456";
The Connection conn=DriverManager. GetConnection (url, name2, password);
//create a connection to connect,
The Statement ps=conn. CreateStatement ();
String sql1="insert into user (username, password, email, number) values ('" + username + "', '" + passwd +"', '" + email + "', '" + phone + ") ";
Ps. ExecuteUpdate (sql1);
Out. Print (" to create a new user successfully "+" & lt; Br/& gt;" );
ps.close();
conn.close();
} the catch (Exception e) {
System. The out. Println (" failed to create a new user "+ um participant etMessage ());
e.printStackTrace();
}
% & gt;



After each submission display is null, the result of the really don't know what to do, don't see the wrong killing me

CodePudding user response:

Why use JSP to handle? JSP is mainly used to control the display, you will interact with the database, using the Servlet doPost () method of the treatment is the right way

CodePudding user response:

A href tag jump will not submit the form

CodePudding user response:

Is a problem with the input is ok, is I am too food, thank you for your reply
  • Related