jsp写文件
现在有个jsp页面,如下:<br><%@ page contentType="text/html; charset=utf-8"%><br><%@ page import="java.io.*,java.sql.PreparedStatement,java.sql.ResultSet"%><br><html><br><head><br></head><br><body><br>您的地址为:<%=request.getRemoteAddr()%><br></body><br></html><br>这个页面可以获得IP地址,现在我想把这个IP地址取出来保存在计算机上的一个文件中,请问应该怎么做啊?在这个页面的基础上实现,谢了<br><br><P><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><BR><html><BR> <head><BR> <base href="<%=basePath%>"><BR> <BR> <title>My JSP 'file.jsp' starting page</title><BR> <BR> <meta http-equiv="pragma" content="no-cache"><BR> <meta http-equiv="cache-control" content="no-cache"><BR> <meta http-equiv="expires" content="0"> <BR> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><BR> <meta http-equiv="description" content="This is my page"><BR> <!--<BR> <link rel="stylesheet" type="text/css" href="styles.css"><BR> --></P>
<P> </head><BR> <BR> <body><BR> <%<BR> String str = request.getRemoteAddr();<BR> File file = new File("C:\\ip.txt");<BR> new FileOutputStream(file).write(str.getBytes());<BR> %><BR> </body><BR></html></P>
页:
[1]
