Html代码:
<form action="insert.jsp" name="form" method="post">
<tr><td colspan=2>Name:</td><td> <input type = "text" name = "pname"></td></tr>
<tr><td colspan=2>Photo:</td><td><input type="file" name="Photo" accept="image/jpeg"></td></tr>
insert.jsp:
<%@ page errorPage = "/pages/error.jsp" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page language="java" import="java.io.*" %>
<%
response.setContentType("text/html");
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
PreparedStatement ps = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:xe";
con=DriverManager.getConnection(url,"system","password");
try{
stmt=con.createStatement();
ps = con.prepareStatement("insert into student values(?, ?)");
ps.setString(2, request.getParameter("pname"));
ps.setString(4, request.getParameter("Photo"));
ps.executeUpdate();
}catch(Exception e){
out.println("error:"+e.getMessage());
}
的问题:
如何检查是否正在插入数据以及如何使用jsp文件显示图像?