在实现密码输入错误,跳转页面时
我是新手,刚学jsp。求教大神。



out.xx 为什么一用就出错,这代码是我跟着书上敲出来的。我也百度了下。说是输出流的内置对象。求大牛给我具体讲解下。
------解决方案--------------------报的啥错呢?
------解决方案--------------------哥们 out对象时JSP的内置对象 所以你可以在JSP中直接使用 但是你不能在JAVA类里面直接使用
如果你想在JAVA类中使用 给你段代码
HttpServletResponse response = null;
PrintWriter pw= null;
try {
response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
pw= response.getWriter();
pw.print(str);
} catch (Exception e) {
} finally {
try {
if (pw != null)
pw.close();
} catch (Exception ex) {
}
}
------解决方案--------------------out是JSP的内置对象 所以你可以在JSP中直接使用,在java中可以看下面的例子
OutputStream out=response.getOutputStream();
PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));
pw.println("<HTML><HEAD><TITLE>输出HTML标签</HEAD></TITLE><BODY>");
pw.println("输出程序中你想输出的部分");
pw.println("</BODY></HTML>");
pw.flush();
pw.close();