Since the contact with JSP, we have been constantly encountering various problems, constantly querying information, and constantly exploring. Compared with ASP. NET, JSP gives me the feeling that the development idea is relatively complicated, the development tool is too automated, and a lot of web page running principles need to be understood.
① The page parameters are garbled when being passed in Chinese.
JSP generally uses the default encoding method when obtaining page parameters. If the encoding type of the page parameters is different from the default encoding type, garbled characters may occur. One way to solve this type of Garbled text problem is to force the request to get the parameter encoding method before obtaining the parameter on the page:
Request. setcharacterencoding ("GBK") or request. setcharacterencoding ("gb2312 ").
Another method is to encode the obtained parameters, for example:
String searchstrtemp = (string) request. getparameter ("text1"). Trim ();
String searchstr = new string (searchstrtemp. getbytes ("8859_1"), "gb2312 ");
② An error occurred while connecting to DB2 using JDBC in JSP
I encountered this strange problem. After the connection parameters are written, you can connect to the DB2 database by default without any settings. Sometimes, the program reports a connection error suddenly. Restart, sometimes it will be better, sometimes it will not work. Later I thought it may be because the program had a problem with DB2 when connecting to the database multiple times, which caused the JDBC Applet Server to be closed. Run the db2jstrt command or start the JDBC Applet Server in the control panel service to solve this problem.