OutJavaScript

java 代码
  1. package com.axon.fable.empolderpackage.out;   
  2. import java.io.BufferedReader;   
  3. import java.io.BufferedWriter;   
  4. import java.io.File;   
  5. import java.io.FileNotFoundException;   
  6. import java.io.FileReader;   
  7. import java.io.IOException;   
  8. import java.io.PrintWriter;   
  9.   
  10. import javax.servlet.http.HttpServletRequest;   
  11. import javax.servlet.http.HttpServletResponse;   
  12.   
  13. import java.io.*;   
  14. /**  
  15.  * 

    @Title: TODO

     
  16.  * 

    @Description: 

     

     
  17.  * 

    Class: reservation com.axon.fable.util out.java 

     
  18.  * 

    Date: 2005 2005-5-21 下午09:09:35

     
  19.  * @Version: 1.0  
  20.  * @CopyRight(C) 2007 axon www.axon-dl.com  
  21.  * @author hero comeon-liming@163.com  
  22.  *   
  23.  */  
  24. public class OutJavaScript {   
  25.   
  26.     private static  String  include="" +   
  27.     "<script language=\"javascript\" type=\"text javascript\" src="\&quot;/sams/samspage/js/alert/myalert.js\&quot;"></script>";   
  28.        
  29. /** script language='javascript'>alert('"+outString+"');" +"" +"document.location='"+path+"';   
  30.  * 弹出消息进行提示,点击确定按钮执行path  
  31.  * @param response   
  32.  * @param request  
  33.  * @param outString   
  34.  * @param path  
  35.  */  
  36. public static void outSendNull(HttpServletResponse response,String outString,String path){   
  37.       String str="+outString+"');setTimeout(\"document.URL='"+path+"'\",\"2000\");" +   
  38.             "" +   
  39.             " "+   
  40.             ">";     
  41.       response.setCharacterEncoding("UTF-8");   
  42.       PrintWriter out=null;   
  43.     try {   
  44.         out = response.getWriter();   
  45.     } catch (IOException e) {   
  46.         // TODO 自动生成 catch 块   
  47.         e.printStackTrace();   
  48.     }      
  49.                                 out.println(""+include+str+"");   
  50.             out.flush();   
  51.     }   
  52. /** script language='javascript'>alert("+outString+"');" +"" +"document.location='"+path+"';   
  53.  * 弹出消息进行提示,点击确定按钮执行path  
  54.  * @param response   
  55.  * @param request  
  56.  * @param outString   
  57.  * @param path  
  58.  */  
  59. public static void outSendNull(HttpServletResponse response,HttpServletRequest request,String outString,String path){   
  60.       String str="+outString+"\");" +   
  61.             "" +   
  62.             "setTimeout(\"document.URL='"+path+"'\",\"2000\");" +   
  63.             ">";     
  64.       response.setCharacterEncoding("UTF-8");   
  65.       PrintWriter out=null;   
  66.     try {   
  67.         out = response.getWriter();   
  68.     } catch (IOException e) {   
  69.         // TODO 自动生成 catch 块   
  70.         e.printStackTrace();   
  71.     }      
  72.             out.println(""+include+str+"");   
  73.             out.flush();   
  74.     }   
  75. /**alert('"+outString+"'); history.back();  
  76.  * 弹出消息进行提示,点击确定按钮返回并刷新页面。  
  77.  * @param response  
  78.  * @param outString  
  79.  */  
  80. public static void outString(HttpServletResponse response,String outString,String backNum){   
  81.          
  82.       String str="+outString+"'); setTimeout('history.back("+backNum+");',2000);\">";     
  83.       response.setCharacterEncoding("UTF-8");   
  84.       PrintWriter out=null;   
  85.         try {   
  86.             out = response.getWriter();   
  87.         } catch (IOException e) {   
  88.             // TODO 自动生成 catch 块   
  89.             e.printStackTrace();   
  90.         }      
  91.                                     out.println(""+include+str+"");   
  92.                 out.flush();   
  93.     }   
  94. /**alert('"+outString+"'); history.back();  
  95.  * 弹出消息进行提示,点击确定按钮返回并刷新页面。  
  96.  * @param response  
  97.  * @param outString  
  98.  */  
  99. public static void outString(HttpServletResponse response,String outString){   
  100.          
  101.       String str="+outString+"');  setTimeout('history.back();',2000);\">";     
  102.       response.setCharacterEncoding("UTF-8");   
  103.       PrintWriter out=null;   
  104.         try {   
  105.             out = response.getWriter();   
  106.         } catch (IOException e) {   
  107.             // TODO 自动生成 catch 块   
  108.             e.printStackTrace();   
  109.         }      
  110.         out.println(""+include+str+"");   
  111.                 out.flush();   
  112.     }   
  113.   
  114.   
  115.   
  116. /**alert('"+outString+"'); history.back();  
  117.  * 弹出消息进行提示,点击确定按钮关闭父窗体。  
  118.  * @param response  
  119.  * @param outString  
  120.  */  
  121. public static void outCloseReload(HttpServletResponse response,String outString){   
  122.          
  123.       String str="+outString+"'); setTimeout('window.close();',2000);\">";     
  124.       response.setCharacterEncoding("UTF-8");   
  125.       PrintWriter out=null;   
  126.         try {   
  127.             out = response.getWriter();   
  128.         } catch (IOException e) {   
  129.             // TODO 自动生成 catch 块   
  130.             e.printStackTrace();   
  131.         }      
  132.             out.println(""+include+str+"");   
  133.                 out.flush();   
  134.     }   
  135. /**alert('"+outString+"'); history.back();  
  136.  * 弹出消息进行提示,点击确定按钮关闭父窗体。  
  137.  * @param response  
  138.  * @param outString  
  139.  */  
  140. public static void outCloseReload2(HttpServletResponse response,String outString){   
  141.          
  142.       String str="+outString+"'); setTimeout('opener.location.reload();window.close();',2000);\">";     
  143.       response.setCharacterEncoding("UTF-8");   
  144.       PrintWriter out=null;   
  145.         try {   
  146.             out = response.getWriter();   
  147.         } catch (IOException e) {   
  148.             // TODO 自动生成 catch 块   
  149.             e.printStackTrace();   
  150.         }      
  151.             out.println(""+include+str+"");   
  152.                 out.flush();   
  153.     }   
  154. /**alert('"+outString+"'); history.back();  
  155.  * 弹出消息进行提示,点击确定按钮关闭父窗体。  
  156.  * @param response  
  157.  * @param outString  
  158.  */  
  159. public static void outClose(HttpServletResponse response,String outString){   
  160.          
  161.       String str="+outString+"'); setTimeout('window.close();',2000);\">";     
  162.       response.setCharacterEncoding("UTF-8");   
  163.       PrintWriter out=null;   
  164.         try {   
  165.             out = response.getWriter();   
  166.         } catch (IOException e) {   
  167.             // TODO 自动生成 catch 块   
  168.             e.printStackTrace();   
  169.         }      
  170.             out.println(""+include+str+"");   
  171.                 out.flush();   
  172.     }   
  173. /**alert('"+outString+"'); history.back();  
  174.  * 弹出消息进行提示,点击确定按钮关闭父窗体然后执行一个PATH。  
  175.  * @param response  
  176.  * @param outString  
  177.  */  
  178. public static void outClose(HttpServletResponse response,String outString,String goPath){   
  179.          
  180.       String str="+outString+"');setTimeout('opener.location="+goPath+";window.close();',2000);\">";     
  181.       response.setCharacterEncoding("UTF-8");   
  182.       PrintWriter out=null;   
  183.         try {   
  184.             out = response.getWriter();   
  185.         } catch (IOException e) {   
  186.             // TODO 自动生成 catch 块   
  187.             e.printStackTrace();   
  188.         }      
  189.                                     out.println(""+include+str+"");   
  190.                 out.flush();   
  191.     }   
  192.   
  193.   
  194. /**alert('"+outString+"'); history.back();  
  195.  * 弹出消息进行提示,点击确定按钮关闭浏览器。  
  196.  * @param response  
  197.  * @param outString  
  198.  */  
  199. public static void outCloseBrower(HttpServletResponse response,String outString){   
  200.          
  201.       String str="<script language='javascript'>" +   
  202.             "        var parwin=null;" +   
  203.             "var b = \"/sams/login.jsp\";" +   
  204.             " if(parent.parent.parent.window!=null)" +   
  205.             " parwin=parent.parent.parent.window;" +   
  206.             "  else if(parent.parent.window!=null)" +   
  207.             " parwin=parent.parent.window;" +   
  208.             "  else if(parent.window!=null)" +   
  209.             "  parwin=parent.window;" +   
  210.             "parwin.opener=null;" +   
  211.             "alert(\""+outString+"\");" +   
  212.             "window.location=b;" +   
  213.             "return;" +   
  214.             "</script>";     
  215.       response.setCharacterEncoding("UTF-8");   
  216.       PrintWriter out=null;   
  217.         try {   
  218.             out = response.getWriter();   
  219.         } catch (IOException e) {   
  220.             // TODO 自动生成 catch 块   
  221.             e.printStackTrace();   
  222.         }      
  223.             out.println(str);   
  224.                 out.flush();   
  225.     }   
  226.   
  227.   
  228.   
  229. public  static void outCloseBrower(HttpServletResponse response,HttpServletRequest request,String outString){   
  230.        
  231.     PrintWriter out;   
  232.     try {   
  233.         response.setCharacterEncoding("utf-8");   
  234.         out = response.getWriter();   
  235. //      out.println(include);   
  236.         out.println("<script language='javascript'>alert('"+outString+" ');setTimeout('',2000);</script>");   
  237.   
  238.         out.println("");   
  239.         out.println("");   
  240.         out.println("<script language=\"javascript\">");   
  241.        
  242.         //out.println("window.opener=null;");   
  243.         //out.println("window.close();");   
  244.         out.println("var subwin=null;");   
  245.         String oper="subwin=open('','','toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,"+   
  246.              "center:yes,menubar=no,copyhistory=no,left=0,top=0,resizable=yes,"+   
  247.              "width=1024,height=768');";   
  248.        
  249.          out.println(oper);   
  250.          out.println("if(subwin!=null)");   
  251.          out.println("{");   
  252.          // out.println("alert('1');");   
  253.          out.println("subwin.document.location='"+request.getContextPath()+"/login.jsp';");   
  254.             
  255.          String str=" var parwin=null;  if(parent.parent.parent.window!=null)" +   
  256.                 " parwin=parent.parent.parent.window;" +   
  257.                 "else if(parent.parent.window!=null)" +   
  258.                 "parwin=parent.parent.window; " +   
  259.                 "else if(parent.window!=null)" +   
  260.                 "parwin=parent.window;";               
  261.          out.println(str+"parwin.opener=null;");   
  262.          out.println("parwin.close();");   
  263.          out.println("}");   
  264.          out.println("else {");   
  265.          out.println("window.name='EasyOfficeMain';");   
  266.          out.println("document.location='"+request.getContextPath()+"/login.jsp';");   
  267.          out.println("}");   
  268.        
  269.        // out.println(op);   
  270.         out.println("</script>");   
  271.         out.println("");   
  272.     } catch (IOException e) {   
  273.         // TODO Auto-generated catch block   
  274.         e.printStackTrace();   
  275.     }   
  276. }   
  277. /**alert('"+outString+"'); history.back();window.location.reload();  
  278.  * 弹出消息进行提示,点击确定按钮返回并刷新页面。  
  279.  * @param response  
  280.  * @param outString  
  281.  */  
  282. public static void reload(HttpServletResponse response,String outString){   
  283.              
  284.           String str="+outString+"'); setTimeout('history.back();window.location.reload();',2000);\">";     
  285.           response.setCharacterEncoding("UTF-8");   
  286.           PrintWriter out=null;   
  287.             try {   
  288.                 out = response.getWriter();   
  289.             } catch (IOException e) {   
  290.                 // TODO 自动生成 catch 块   
  291.                 e.printStackTrace();   
  292.             }      
  293.                                         out.println(""+include+str+"");   
  294.                     out.flush();       
  295.   
  296.         }   
  297.   
  298.  /**if(!window.confirm('"+outString+"')){history.back();}else{" +"" +"document.location='"+path+"'; "+"}  
  299.  * 如果点击弹出框的确定按钮,那么招执行path,否则返回.  
  300.  * @param response  
  301.  * @param request  
  302.  * @param outString  
  303.  * @param path  
  304.  */  
  305. public static void outString(HttpServletResponse response,HttpServletRequest request,String outString,String path){   
  306.            
  307.       String str="";     
  308.        
  309.           str="<script language='javascript'>if(!window.confirm('"+outString+"')){history.back();}else{" +   
  310.             "" +   
  311.             "document.location='"+path+"'; "+   
  312.                 "}</script>";     
  313.           response.setCharacterEncoding("UTF-8");   
  314.           PrintWriter out=null;   
  315.             try {   
  316.                 out = response.getWriter();   
  317.   
  318.             } catch (IOException e) {   
  319.                 // TODO 自动生成 catch 块   
  320.                 e.printStackTrace();   
  321.             }      
  322.   
  323.                     out.println(str);   
  324.                     out.flush();   
  325.                          
  326.   
  327.     }   
  328.   
  329.     public static void reloadWithMessageShow(HttpServletResponse response,HttpServletRequest request,String message1,String message2,boolean isSuccess){   
  330.            
  331.   
  332.         String str="<script language='javascript'>";     
  333.           response.setCharacterEncoding("UTF-8");   
  334.           PrintWriter out=null;   
  335.             try {   
  336.                 out = response.getWriter();   
  337.                    
  338.                   out.println(str);   
  339.                   out.println("opener.alert("+'"'+""+message1+message2+""+'"'+")");   
  340.                   out.println("setTimeout('opener.location.reload();',2000); ");   
  341.                   out.println("window.close();");   
  342.                   out.println("</script>");   
  343.                    
  344.             } catch (IOException e) {   
  345.                 // TODO 自动生成 catch 块   
  346.                 e.printStackTrace();   
  347.             }      
  348.                     out.println(str);   
  349.                     out.flush();       
  350.   
  351.     }   
  352.     public static void responseDiv(HttpServletResponse response,HttpServletRequest request,String message1,String message2,boolean isSuccess){   
  353.            
  354.   
  355.          BufferedReader bufread ;   
  356.          String filepath,read;   
  357.          try{   
  358.          filepath=request.getRealPath("/samspage/js/out/end.txt");   
  359.          File file=new File(filepath);   
  360.          FileReader fileread= null;   
  361.   
  362.             fileread = new FileReader(file);   
  363.             bufread=new BufferedReader(fileread);   
  364.             response.setCharacterEncoding("UTF-8");   
  365.             PrintWriter out=null;   
  366.             out = response.getWriter();   
  367.           while((read=bufread.readLine())!=null){      
  368.               System.out.println(read);   
  369.               out.println(read);   
  370.           }   
  371.              
  372.           out.println(" var caption = "+'"'+"短消息提示:"+'"'+";var message = "+'"'+message1+'"'+";var title = "+'"'+message2+'"'+";");   
  373.           out.println("window.dialogHeight="+'"'+"150px"+'"'+";window.dialogWidth="+'"'+"280px"+'"'+";window.dialogLeft=screen.width/2-140;window.dialogTop="+'"'+"375px"+'"'+";var w   ="+'"'+"50px"+'"'+";var h   ="+'"'+"50px"+'"'+";");   
  374.                
  375.           filepath=request.getRealPath("/samspage/js/out/responseHtml.txt");   
  376.           file=new File(filepath);   
  377.           fileread= null;   
  378.           fileread = new FileReader(file);   
  379.           bufre
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值