这是公司新来的一个毕业生写的一个jsp文件,里面的代码确实让我很失望。这段代码确实可以做一个教材了,不过是反面的。代码如下:
大家都说说这段代码里面有哪些问题,会产生什么样的后果。
<%@ page import="com.*.db.util.DBConnectionPool"%>
<%@ page import="com.*.db.util.MyConnection"%>
<%@ page import="com.*.db.util.ConnectionPool"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%
request.setCharacterEncoding("UTF-8");
String text = request.getParameter("text");
System.out.println("GBN2312--->>>" + text);
System.out.println("wangjinghui" + text);
String sheetKey = request.getParameter("sheetKey");
MyConnection conn = ConnectionPool.getInstance().getConnection();
String sql = "update temp_tasklinkmain set link_task_info = ? where sheet_id = (select id from tasksheet_template_main where sheet_id = ?)";
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1,text);
stmt.setString(2,sheetKey);
stmt.executeUpdate();
try {
stmt.close();
} catch(Exception e) {
stmt.close();
conn.rollback();
e.printStackTrace();
} finally {
conn.close();
}
response.setCharacterEncoding("GB2312");
out.println(text);
out.flush();
%>
大家都说说这段代码里面有哪些问题,会产生什么样的后果。