jsp调试问题 解决后加分~~~
源程序包我引入了<bodybackground=001.jpg><%ArrayList<String>info=newArrayList<String>();String...
源程序 包我引入了
<body background=001.jpg>
<%
ArrayList <String> info = new ArrayList<String>();
String username=request.getParameter("ustr");
info.add(username);
String passWord=request.getParameter("myPassword");
info.add(passWord);
try{
BufferedWriter bw = new BufferedWriter(new FileWriter("d:/jsp.txt",true));
for (int i = 0; i<info.size(); i++) {
bw.write(info.get(i));
bw.newLine();
}
bw.flush();
bw.close();
} catch (IOException m) {
m.printStackTrace();
}
%>
错误提示:
org.apache.jasper.JasperException: An exception occurred processing JSP page /homework/bian.jsp at line 102
99:
100: BufferedWriter bw = new BufferedWriter(new FileWriter("d:/jsp.txt",true));
101: for (int i = 0; i<info.size(); i++) {
102: bw.write(info.get(i));
103: bw.newLine();
104: }
105: bw.flush();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 展开
<body background=001.jpg>
<%
ArrayList <String> info = new ArrayList<String>();
String username=request.getParameter("ustr");
info.add(username);
String passWord=request.getParameter("myPassword");
info.add(passWord);
try{
BufferedWriter bw = new BufferedWriter(new FileWriter("d:/jsp.txt",true));
for (int i = 0; i<info.size(); i++) {
bw.write(info.get(i));
bw.newLine();
}
bw.flush();
bw.close();
} catch (IOException m) {
m.printStackTrace();
}
%>
错误提示:
org.apache.jasper.JasperException: An exception occurred processing JSP page /homework/bian.jsp at line 102
99:
100: BufferedWriter bw = new BufferedWriter(new FileWriter("d:/jsp.txt",true));
101: for (int i = 0; i<info.size(); i++) {
102: bw.write(info.get(i));
103: bw.newLine();
104: }
105: bw.flush();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 展开
展开全部
String username=request.getParameter("ustr");
String passWord=request.getParameter("myPassword");
这username,passWord取不到值造成
你debug一下就知道了,可加null判断
String passWord=request.getParameter("myPassword");
这username,passWord取不到值造成
你debug一下就知道了,可加null判断
更多追问追答
追问
恩对 他一直为空 根本传不进来参数 到底是怎么回事呢
追答
String username=request.getParameter("ustr");
这样用的话是要求地址是http://www.xxx.jsp?ustr=username&?myPassword=password,或者是表单以post、get方式传过来的。
你要明白request的作用域,如果你的用户名和密码是用于整个网站的话,最好把它放到session里去。
你如果改为String username="admin",String passWord="123" 这程序是能通过的,并能保存到txt里去的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询