日期:2014-05-17 浏览次数:20687 次
<%@page import="org.apache.catalina.Store"%> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.io.*,java.util.Properties"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <% String ip = null; String account = null; String password = null; if(request!=null){ try{ Properties P = new Properties(); String filePath = getClass().getResource("/").getPath()+"ip.properties"; File file = new File(filePath); FileOutputStream outputFile = new FileOutputStream(file); if(ip!=request.getParameter("ip")){ P.setProperty("IP", request.getParameter("ip")); P.store(outputFile, "Update 'IP' value"); } if(account != request.getParameter("account")){ P.setProperty("Account", request.getParameter("account")); P.store(outputFile, "Update 'Account' value"); } if(password !=request.getParameter("password")){ P.setProperty("Password", request.getParameter("password")); P.store(outputFile, "Update 'Password' value"); } outputFile.close(); }catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } try{ Properties P = new Properties(); InputStream in = this.getClass().getResourceAsStream("/ip.properties"); P.load(in); in.close(); ip = P.getProperty("IP"); account = P.getProperty("Account"); password = P.getProperty("Password"); }catch (FileNotFoundException e) { e.printStackTrace(); }catch (IOException ioe){ ioe.printStackTrace(); } %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>显示IP</title> </head> <body> IP:<input type ="text" name ="ip" size="20" value=<%=ip%>><p> account:<input type="text" name="account" size="20" value=<%=account%>><p> password:<input type="password" name="password" size="20" value=<%=password%>><p> <form action = "login.jsp" method = "post"> <input type = "submit" value="返回"> </form> <form method = "post"> <input type = "submit" value="修改"> </form> </body> </html>