我的页面是一个 
 <input type="file" name="file"  id="file">
      <br>
      <input type="text" align="top"  style="width: 300px;height:300px;background-color: white"  > 

我选择好文件以后 要马上把文件的内容读到文本框里面 
   读写的方法已经写好了
       这个怎么连起来  

解决方案 »

  1.   

    通过form表单去获取,事件触发后将值写入。
      

  2.   

    struts1:FormFile封装  FileUpForm upForm=(FileUpForm)form;
      FormFile formFile=upForm.getMyFile();
      InputStream in=formFile.getInputStream();struts2:File封装
      

  3.   

    读写的方法写在服务器端的话,就直接用ajax来传输数据
    没有经过封装最原始的:
    <script language="JavaScript" type="text/javascript">
    var xmlHttp = false;
    function createXMLHttpRequest(){
    if(window.ActiveXObject){
    xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
    }else if(window.XMLHttpRequest){
    xmlHttp = new XMLHttpRequest();
    }
    }
    function strParse(){
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = callback;
    xmlHttp.open("post","test.action",true);
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
    xmlHttp.send(null);
    function callback(){
    if(xmlHttp.readyState==4){
    if(xmlHttp.status==200){
    var data = xmlHttp.responseText;
    var spNode = document.getElementById("file");
    spNode.innerHTML = data;
    }
    }else{
     document.getElementById("file").innerHTML="正在读取...";
    }
    }

    }
    </script>
    服务器端只要这么输出:
    PrintWriter out = response.getWriter();
    out.print(".....");
      

  4.   

    要显示的页面放一个控件,传上去之后通过window.opener.form1.jjpic.value = 'value';的方式可以将值跨页面传过去