求助!我的程序出问题了!

w_hb 2004-10-28 08:27:18
编了个程序想要使使用者完成基本数据的输入在浏览网页,可是总出问题。程序代码如下

send.html
<HTML>
<TITLE>方法使用</TITLE>
<BODY>
<center>方法使用</center>
<hr>
<FORM action="send.jsp" method=post name=form1>
姓名:<input type=text name=txtname> <br>
密码:<input type=password name=txtpassword> <br>
<input name=submit type=submit vlue=提交>
</FORM>
</BODY>
</HTML>


send.jsp
<%@ page contentType="text/html;charset=GB2312"%>
<%
String Name=request.getParameter("txtname");
String Pass=request.getParameter("txtpassword");
if(Name.equals("")||Pass.equals(""))
response.sendRedirect("send.html");
%>
<HTML>
<TITLE>方法使用</TITLE>
<BODY>
<center>方法使用</center>
<hr>
姓名:"<% = Name% >" <br>
密码:"<% = Pass% >" <br>
</BODY>
</HTML>
...全文
108 点赞 收藏 20
写回复
20 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
mhz 2004-10-29
send.html
<HTML>
<TITLE>方法使用</TITLE>
<BODY>
<center>方法使用</center>
<hr>
<FORM action="send.jsp" method=post name=form1>
姓名:<input type=text name=txtname> <br>
密码:<input type=password name=txtpassword> <br>
<input name=submit type=submit value=提交>
</FORM>
</BODY>
</HTML>
send.jsp
<%@ page contentType="text/html;charset=GB2312"%>
<%
String Name=request.getParameter("txtname");
String Pass=request.getParameter("txtpassword");
if(Name.equals("")||Pass.equals(""))
response.sendRedirect("send.html");
%>
<HTML>
<TITLE>方法使用</TITLE>
<BODY>
<center>方法使用</center>
<hr>
姓名:<%=Name%> <br>
密码:<%=Pass%> <br>
</BODY>
</HTML>
改为上边的,运行成功,
你在试试
书写时注意标点符号
希望你能好好看看书!
回复
monkeyhjl 2004-10-29
String Name=new String((request.getParameter("txtname")).getBytes("8859_1"));
这样就不会乱码了。
回复
monkeyhjl 2004-10-29
tom2005(快乐着) 正确。
全角的分号和半角的分号出问题了。
不过你这个中文还是会乱码的!
回复
klend 2004-10-29
把这行去掉-〉
<%@ page contentType="text/html;charset=GB2312"%>
回复
tom2005 2004-10-29
<%@ page contentType="text/html;charset=GB2312" %>
改为
<%@ page contentType="text/html;charset=GB2312" %>

回复
w_hb 2004-10-29
再补充一下
改过后的代码:
send.html
<HTML>
<TITLE>方法使用</TITLE>
<BODY>
<center>方法使用</center>
<HR>
<FORM action="send.jsp" method=post name=form1>
姓名:<input type=text name=txtname> <BR>
密码:<input type=password name=txtpassword> <BR>
<input name=submitl type=submit value=提交>
</FORM>
</BODY>
</HTML>

send.jsp
<%@ page contentType="text/html;charset=GB2312" %>
<%
String Name=request.getParameter("txtname");
String Pass=request.getParameter("txtpassword");
if(Name.equals("")||Pass.equals(""))
response.sendRedirect("send.html");

%>
<HTML>
<TITLE>方法使用</TITLE>
<BODY>
<center>方法使用</center>
<HR>
姓名:"<%= Name %>"<BR>
密码:"<%= Pass %>"<BR>
</BODY>
</HTML>
回复
w_hb 2004-10-29
我又把<input name=submit type=submit vlue=提交>改成
<input name=submitl type=submit value=提交>
又出现了新问题,运行send.html输入相关内容后按“提交”
按钮后出现一个文件下载提示框,问是打开还是保存,我选择打开后,
呈现下列界面
send[1].jsp

<HTML>
<TITLE>????</TITLE>
<BODY>
<center>????</center>
<HR>
???"禾塔比"<BR>
???"123456"<BR>
</BODY>
</HTML>

我有些糊涂了,这是为什么
回复
紫翎观星 2004-10-29
你这样写试试:
<%@ page contentType="text/html;charset=GB2312"%>
<%
String Name=request.getParameter("txtname");
String Pass=request.getParameter("txtpassword");
%>
<HTML>
<TITLE>方法使用</TITLE>
<BODY>
<center>方法使用</center>
<hr>
姓名:"<% = Name% >" <br>
密码:"<% = Pass% >" <br>
</BODY>
</HTML>
<%
response.sendRedirect("send.html");
%>
回复
w_hb 2004-10-29
自己看书又找到解决中文乱码的办法了,不好意思
回复
紫翎观星 2004-10-29
而且,response.sendRedirect("send.html")这个方法必须在响应提交前被调用,也就是在状态码和页首被写入前被调用。问题的关键就在这!!!
回复
紫翎观星 2004-10-29
request.getParameter返回的本来就是字符串!
还有,"response.sendRedirect("send.html");"这句后面要加句"return;"!
回复
snow_jin 2004-10-29
String Name=request.getParameter("txtname");
String Pass=request.getParameter("txtpassword");
〉〉
String Name=(String)request.getParameter("txtname");
String Pass=(String)request.getParameter("txtpassword");
回复
monkeyhjl 2004-10-29
把你改过后的send.jsp代码贴出来看看
回复
w_hb 2004-10-29
hj821003(荒原小草): 我按照你说的改了,可是又有新的提示信息


org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 12 in the jsp file: /jsp/send.jsp

Generated servlet error:
[javac] Compiling 1 source file

D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\send_jsp.java:56: illegal start of expression
= Name
^



An error occurred at line: 13 in the jsp file: /jsp/send.jsp

Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\send_jsp.java:59: illegal start of expression
= Pass
^
2 errors
回复
w_hb 2004-10-29
虽然结贴了,但又出现问题了
我又运行了一下,这回居然出现中文乱码了
怎么这么不稳定呢,刚才还好好的
回复
w_hb 2004-10-29
多谢各位的帮助,特别是 mhz(无奈.孤独)
你说的很有道理,下来我会好好看书!
回复
yuaoyao 2004-10-28
楼上的说的对
回复
hj821003 2004-10-28
姓名:"<% = Name% >" <br>
密码:"<% = Pass% >" <br>

>>
姓名:"<%= Name %>" <br>
密码:"<%= Pass %>" <br>

回复
w_hb 2004-10-28
请帮我分析一下原因吧
回复
w_hb 2004-10-28
运行send.html输入相关内容后按“提交”按钮后出现以下提示:
org.apache.jasper.JasperException: /jsp/send.jsp(12,7) Unterminated <% tag
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:428)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:170)
at org.apache.jasper.compiler.Parser.parseScriptlet(Parser.java:440)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:801)
at org.apache.jasper.compiler.Parser.parse(Parser.java:122)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:199)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:153)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:227)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:369)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)

回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告