把内容写如文件的入门级问题
<%@ page contentType= "text/html; charset=gb2312 " import= "java.io.* " buffer= "64kb "%>
<html>
<body>
<%
request.setCharacterEncoding( "gb2312 ");
String content=request.getParameter( "content ");
%>
<%
try
{
PrintWriter writer= new PrintWriter(new BufferedWriter(new FileWriter( "C:\\Tomcat\\webapps\\jsp\\test\\test.txt ",true)));
writer.write(content);
writer.close();
out.println( "已经把内容写入到 C:\Tomcat\webapps\jsp\test\test.txt ");
}
catch(Exception e)
{
out.println(e);
e.printStackTrace();
}
%>
<form action= "writeFile.jsp " method=post>
<textarea name=content cols=20 rows=5> </textarea> <br>
<input type=submit value=提交>
</form>
</body>
</html>
=============================
错误提示:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the jsp file: /writeFile.jsp
Invalid escape sequence (valid ones are \b \t \n \f \r \ " \ ' \\ )
5: request.setCharacterEncoding( "gb2312 ");
6: String content=request.getParameter( "content ");
7: %>
8: <%
9: try
10: {
11: PrintWriter writer= new PrintWriter(new BufferedWriter(new FileWriter( "C:\\Tomcat\\webapps\\jsp\\test\\test.txt ",true)));
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
======================================
请高手指教啊~
------解决方案------------------