在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)

...全文
146 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
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>

你的程序有问题,发生空指针

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧