form中的action问题!

bengan 2004-05-08 10:31:18
我写以下代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<jsp:useBean id="mysqlCon" scope="page" class="db.mysqlConn"/>
<title>无标题文档</title>
</head>

<body>
<%
String ss=request.getParameter("ss");
out.print(ss);
String type=request.getParameter("type");
if(type.equals("big")){
out.print("添加大类");
%>
<form action="add.jsp">
<input name="ss" type="submit" value="提交">
</form>
<%
}
if(type.equals("ok"))
out.print("type=ok");
%>
</body>
</html>
第一次进入没问题。但点激“提交”按钮有以下出错提示:
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:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NullPointerException
org.apache.jsp.tp.add_jsp._jspService(add_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.19
...全文
40 2 点赞 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Dog2Cat 2004-05-08
问题出在:
<form action="add.jsp">
<input name="ss" type="submit" value="提交">
</form>
本页面(ADD.JSP)开始有接受表单项的语句:
String ss=request.getParameter("ss");
String type=request.getParameter("type");
但ADD.JSP页中的表单提交到本页时没有对应的表单项,故出错。
修改:
将ADD.JSP的表改为:
<form action="add.jsp">

<input name="ss" type="hidden" value=<%=ss%>>
<input name="type" type="hidden" value=<%=type%>>

<input name="ss" type="submit" value="提交">
</form>
  • 打赏
  • 举报
回复
bengan 2004-05-08
add.jsp就是本页的名称。我是想action回本页!
  • 打赏
  • 举报
回复
相关推荐
发帖
Web 开发
加入

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-05-08 10:31
社区公告
暂无公告