内容发布更新时间 : 2024/12/23 18:20:18星期一 下面是文章的全部内容请认真阅读。
input.jsp:
<%@ page contentType=\
输入文件名字: read.jsp:
<%@ page contentType=\<%@ taglib tagdir=\
String s1=request.getParameter(\ String s2=request.getParameter(\ if(s1.length()>0&&s2.length()>0) {
%> 读取的文件内容:
<%=content%> <% } %> Read.tag:
<%@ tag pageEncoding=\<%@ tag import=\
<%@ attribute name=\<%@ attribute name=\<%@ variable name-given=\<%
StringBuffer str=new StringBuffer(); try{
File f=new File(dirName,fileName);
11
FileReader in=new FileReader(f);
BufferedReader bufferin=new BufferedReader(in); String temp;
while((temp=bufferin.readLine())!=null) { str.append(temp); }
bufferin.close(); in.close(); }
catch(IOException e) {
str.append(\ }
jspContext.setAttribute(\%>
习题六
1.答:
a.jsp:
表查询到记录: <%=queryResult %>
<%@ attribute name=\<%@ attribute name=\<%@ variable name-given=\<%@ variable name-given=\
12
<%
StringBuffer result; result=new StringBuffer(); try {
Class.forName(\ }
catch(Exception e) {
out.print(e); }
Connection con; Statement sql; ResultSet rs;
try{ result.append(\
String uri= \ String user=\ String password=\
con=DriverManager.getConnection(uri,user,password); DatabaseMetaData metadata=con.getMetaData();
ResultSet rs1=metadata.getColumns(null,null,tableName,null); int 字段个数=0; result.append(\ while(rs1.next()) { 字段个数++;
String clumnName=rs1.getString(4); result.append(\ }
result.append(\ sql=con.createStatement();
rs=sql.executeQuery(\ while(rs.next())
{ result.append(\ for(int k=1;k<=字段个数;k++)
{ result.append(\ }
result.append(\ }
result.append(\ con.close(); 13
}
catch(SQLException e)
{ result.append(\请输入正确的用户名和密码\ }
jspContext.setAttribute(\ jspContext.setAttribute(\%>
2.答:
b.jsp:
添加的记录是: <%=newRecord %>
<%@ attribute name=\<%@ attribute name=\<%@ attribute name=\<%@ attribute name=\<%@ attribute name=\<%@ variable name-given=\<%@ variable name-given=\<%
float p=Float.parseFloat(price); String condition=
\
\ try{
Class.forName(\
14
catch(Exception e) {} Connection con; Statement sql; ResultSet rs; try{
String uri= \ con=DriverManager.getConnection(uri,\ sql=con.createStatement(); sql.executeUpdate(condition); con.close();
String str=(\ jspContext.setAttribute(\ }
jspContext.setAttribute(\ }
3.答:
c.jsp:
更新后的记录是: <%=reNewRecord %>
<%@ attribute name=\<%@ attribute name=\
15