在jsp中,如何实现一个web页提交给本页,要传递参数的方法/谢谢

shaokun305 创始人  2003-04-09 05:35:26
另外谁可以解释下面的系统信息:
Internal Servlet Error:

javax.servlet.ServletException
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
at jsp.xiangmu._0002fjsp_0002fxiangmu_0002frenwu_00038_0002ejsprenwu8_jsp_0._jspService(_0002fjsp_0002fxiangmu_0002frenwu_00038_0002ejsprenwu8_jsp_0.java:188)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:536)

Root cause:
java.lang.NullPointerException
at jsp.xiangmu._0002fjsp_0002fxiangmu_0002frenwu_00038_0002ejsprenwu8_jsp_0._jspService(_0002fjsp_0002fxiangmu_0002frenwu_00038_0002ejsprenwu8_jsp_0.java:179)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:536)

...全文
107 点赞 收藏 13
写回复
13 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
colacoca 2003-04-09
1.jsp
...
<form method="post" action="2.jsp"
<input ....name="name"
...

2.jsp
name=request.getParameter("name");
<form method="post" action="this">
<input type="hidden" name="name" value="<%=name%>" > <-------这句话传递
if(name.....)
..

2提交后

String name=request.getParameter("name");
得到
回复
colacoca 2003-04-09
1.jsp
...
<form method="post" action="2.jsp"
<input ....name="name"
...

2.jsp
name=request.getParameter("name");
<form method="post" action="this">
<input type="hidden" name="name" value="<%=name%>" >
if(name.....)
..

2提交后

String name=request.getParameter("name");
得到

回复
summer0119 2003-04-09
俺也不懂
回复
teva 2003-04-09
第二个网页提交给自己的时候,第一个网页上面的变量也好,域也好,都不在了;

可能的方法,包括全局变量 <%! %>
session
回复
skyboot02 2003-04-09
用全局变量保存这个值
回复
shaokun305 2003-04-09
好象还说说不清了呢/是这样;
1.jsp
...
<form method="post" action="2.jsp"
<input ....name="name"
...

2.jsp
name=request.getParameter("name");
<form method="post" action="this">
if(name.....)
..
请问如何保留name 的值呢??
回复
wellsoon 2003-04-09

是不是这样???

<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
posttoself
</title>
</head>
<body bgcolor="#ffffff">
<h1>Post to self test</h1>
<form method="post" >
<br>请输入一个数字 : <input name="num"><br>
<input type="submit" name="Submit" value="提交" >
<input type="reset" value="清除">
<br>你输入的数字是<%=request.getParameter("num")%>
<br>
</form>
</body>
</html>

回复
shaokun305 2003-04-09
?????????不懂/
回复
曲阿子期 2003-04-09
像平常一样做,只不过在开头加个
String mth=requet.getMethod()
if (mth.equals("GET")){
....
else{
...
回复
shaokun305 2003-04-09
具体说吧:
....
name=request.getParameter("name");
....
<form method="post" action="this">
........
那么:如何保留name的值呢?
回复
lEFTmOON 2003-04-09
同意楼上的
回复
shaokun305 2003-04-09
小弟不知道,举个例子吧:第二个网页有第一个网页的变量,第二个网页要提交给自己,那么,第一个网页的参数如何保存给提交自己的网页呢?
回复
Koham 2003-04-09
<form method=post action="this">
...
</form>

你的程序有问题,发生空指针
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2003-04-09 05:35
社区公告
暂无公告