Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Servlet/JSP/JSF/JavaFX Script
打印话题 寄给朋友 订阅主题 |
作者 | 帮我诊断一下? |
ququ_0811
发贴: 17 |
于 2005-05-13 20:54
<html> <head> <title>ququ留言板</title> </head> <body bgcolor="#ccccff" vlink="#000000" alink="#666666"> <div align="center"> <p><font size="7"> <b><font size="+6">蛐蛐驿站 </font></b> </font></p> <form method="post" action="index.jsp"> <table width="75%" align="center" border=1> <tr> <td width="30%"> <div align="right">姓名 :</div> </td> <td width="70%"> <input type="text" name="name"> </td> <tr> </tr> <td width="30%"> <div align="right">电子邮件 :</div> </td> <td width="70%"> <input type="text" name="email"> </td> </tr> <tr> <td width="30%"> <div align="right">个人主页地字 :</div> </td> <td width="70%"> <input type="text" name="url" value="http://"> </td> </tr> <tr> <td width="30%"> <p>请你留言</p> </tr> <td width="70%"> <textarea name="body" rows="5" cols="30"></textarea> </td> </tr> <tr> <td width="30%"> </td> <td width="70%"> </td> </tr> <tr> <td width="30%"> </td> <td width="70%"> <table width="75"> </tr> <td> <input type="submit" name="send" value="提交"> </td> <td> <input type="reset" name="reset" value="重置"> </td> </tr> </table> </td> </tr> </table> </form> <hr> </div> </body> </html> <html> <head> </head> <body> <%@ page language="java"import="java.sql.*,ququ.sql" %> <%@ page contentType="text/html;charset=gb2312" %> <jsp:useBean id="sqlbean" class="ququ.sql" scope="session"/> <%! String name,email,url,body,sql; %> <% name=request.getParameter("name"); email=request.getParameter("email"); url=request.getParameter("url"); body=request.getParameter("body"); if(name!=""&&email!=""&&body!="") { sql="insert into guestbook(name,email,url,body)values('"+name+"','"+email+"','"+url+"','"+body+"')"; sqlbean.executeInsert(sql); } else { out.print("<b><font color=red >sorry ,please enter your name ,url ,email.and body!!!</font></b>"); } %> <% ResultSet RScount = sqlbean.executeQuery("SELECT * FROM guestbook"); int i=0; while(RScount.next()) { i++; } %> <%-- <p> --%> <p><b>现在?%=i %> 条纪录</b></p> <% RScount.close(); i=0; %> <p> </p> <% ResultSet RS=sqlbean.executeQuery("SELECT * FROM guestbook"); while(RS.next()) { name=RS.getString("name"); email=RS.getString("email"); url=RS.getString("url"); body=RS.getString("body"); %> <table border=1 width=80%> <tr> <td width=30%>昵称:</td><td width=70% ><%=name%> </tr> <tr> <td width=30%>电子邮件:</td><td width=70% ><a herf="mailto:<%=email%>"><%=email%></a></td> </tr> <tr> <td width=30%>个人主页:</td><td width=70% ><a herf="<%=url%>"><%=url%></a></td> </tr> <tr> <td width=30%>内容:</td><td width=70% ><%=body%></td> </tr> </table> <hr> <% } RS.close(); %> </body> </html> package ququ; import java.sql.*; public class sql { String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; String sConnStr="jdbc:odbc:mydata"; Connection conn=null; ResultSet rs=null; public sql() { try { Class.forName(sDBDriver); }catch(java.lang.ClassNotFoundException e) { System.err.println("sql():"+e.getMessage()); }catch(java.lang.NullPointerException e) { System.err.println("sql():"+e.getMessage()); } } public void executeInsert(String sql) { try { conn=DriverManager.getConnection(sConnStr); Statement stmt=conn.createStatement(); stmt.executeUpdate(sql); }catch(SQLException ex) { System.err.println("sql.executeUpdata:"+ex.getMessage()); } } public ResultSet executeQuery(String sql) { rs=null; try { conn=DriverManager.getConnection(sConnStr); Statement stmt=conn.createStatement(); rs=stmt.executeQuery(sql); }catch(SQLException ex) { System.err.println("sql.executeUpdata:"+ex.getMessage()); } return rs; } public void executeDelete(String sql) { try { conn=DriverManager.getConnection(sConnStr); Statement stmt=conn.createStatement(); stmt.executeUpdate(sql); }catch(SQLException ex) { System.err.println("sql.executeUpdata:"+ex.getMessage()); } } } 运行结果 HTTP Status 500 - -------------------------------------------------------------------------------- type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NullPointerException org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:85) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs. -------------------------------------------------------------------------------- Apache Tomcat/5.5.7 大哥们,小弟初学请指教。 Java开发规范 |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
1295 | 帮我诊断一下? | ququ_0811 | 5779 | 2005-05-13 20:54 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |