heting

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  40 随笔 :: 9 文章 :: 45 评论 :: 0 Trackbacks

#

import uk.ltd.getahead.dwr.WebContext;   
import uk.ltd.getahead.dwr.WebContextFactory;   
  
   
  
WebContext ctx 
= WebContextFactory.get();                         //DWR Web上下文工厂   
HttpServletRequest request = ctx.getHttpServletRequest();  //通过WebContext获取Request   
HttpSession session = ctx.getSession();                                //通过WebContext获取Session  
posted @ 2008-11-17 12:55 贺挺 阅读(166) | 评论 (0)编辑 收藏

index.html
<HTML> 
<HEAD> 
<TITLE> New Document </TITLE> 
<META NAME="Generator" CONTENT="EditPlus"> 
<META NAME="Author" CONTENT=""> 
<META NAME="Keywords" CONTENT=""> 
<META NAME="Description" CONTENT=""> 
</HEAD> 

<BODY> 
<INPUT TYPE="button" value="按钮" onclick="wopen()"> 
</BODY> 
</HTML> 
<SCRIPT LANGUAGE="vbScript"> 
<!-- 
sub wopen() 
window.open 
"t2.htm","","height=300,width=300" 
end sub 
//--> 
</SCRIPT> 

children.html
<HTML> 
<HEAD> 
<TITLE> New Document </TITLE> 
<META NAME="Generator" CONTENT="EditPlus"> 
<META NAME="Author" CONTENT=""> 
<META NAME="Keywords" CONTENT=""> 
<META NAME="Description" CONTENT=""> 
</HEAD> 

<BODY> 
<INPUT TYPE="button" value="按钮" onclick="ref()"> 
</BODY> 
</HTML> 
<SCRIPT LANGUAGE="vbScript"> 
<!-- 
sub ref() 
window.opener.location.reload() 
end sub 
//--> 
</SCRIPT>
posted @ 2008-11-10 09:21 贺挺 阅读(975) | 评论 (1)编辑 收藏

 1  
import sun.misc.BASE64Decoder;
  
public static String getFromBASE64(String s) 
 2        if (s == nullreturn null
 3        BASE64Decoder decoder = new BASE64Decoder(); 
 4        try 
 5        byte[] b = decoder.decodeBuffer(s); 
 6        return new String(b); 
 7        }
 catch (Exception e) 
 8        return null
 9        }
 
10    }

11    public static String getBASE64(String s) 
12        if (s == nullreturn null
13        return (new sun.misc.BASE64Encoder()).encode( s.getBytes() ); 
14    }
 
15    
posted @ 2008-11-08 10:47 贺挺 阅读(1599) | 评论 (0)编辑 收藏

 1public String getOneHtml(String htmlurl, String bianma) throws IOException {
 2        URL url;
 3        String temp;
 4        final StringBuffer sb = new StringBuffer();
 5        StringBuffer sb2 = new StringBuffer();
 6        //因为htmlurl字符串中如果出现空白的字符就会出异常
 7        String [] htmlurls=htmlurl.split(" ");
 8        for (int i = 0; i < htmlurls.length; i++{
 9            if ("".equals(htmlurls[i])) {
10                continue;
11                }

12            sb2.append(htmlurls[i]);
13        }

14        try {
15            url = new URL(sb2.toString());
16            final BufferedReader in = new BufferedReader(new InputStreamReader(
17                    url.openStream(), bianma));
18            while ((temp = in.readLine()) != null{
19                sb.append(temp);
20            }

21            in.close();
22        }
 catch (final MalformedURLException me) {
23            // System.out.println("the url is error");
24            me.getMessage();
25            throw me;
26        }
 catch (final IOException e) {
27            e.printStackTrace();
28            throw e;
29        }

30        return sb.toString();
31    }
posted @ 2008-11-08 10:42 贺挺 阅读(160) | 评论 (0)编辑 收藏


<div style="border:1px dashed #000;">
你好这是一个虚线层
<br/></div>
posted @ 2008-11-08 10:40 贺挺 阅读(461) | 评论 (0)编辑 收藏

<generator class="sequence"> <param name="sequence">seq_somename</param> </generator>
posted @ 2008-10-24 00:08 贺挺 阅读(300) | 评论 (0)编辑 收藏

PDF:
(1)利用response的outputString输出:
 
            response.setContentType("application/pdf");
                   //对应报表里面的Field
                  JRBeanCollectionDataSource jrb=new JRBeanCollectionDataSource(List或Set集合);
                  //Map集合对应报表里面的Parameter
           
    byte[] pdfs=JasperRunManager.runReportToPdf(Test.class.getResourceAsStream("heting.jasper"), Map集合, jrb);
              response.getOutputStream().write(pdfs, 
0, pdfs.length);
(2)
Map parameters=new HashMap();
            parameters.put(
"today"new Date());
            List
<Users> users=Make.getList();
            JRBeanCollectionDataSource jrb
=new JRBeanCollectionDataSource(users);
             JasperPrint jasperPrint 
=
                    JasperFillManager.fillReport(Test.
class.getResourceAsStream("heting.jasper"), parameters, jrb
                    );
             
             JRXlsExporter exporter 
= new JRXlsExporter(); 
                response.reset();
                response.setContentType(
"application/vnd.ms-excel"); 
                response.setHeader(
"Content-Disposition""attachment;filename=\"aa.xls\""); 
                exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); 
                exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE); 
                exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
                exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); 
                 exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, 
"GBK");
                exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,response.getOutputStream()); 

                exporter.exportReport();
HTML:


JRBeanCollectionDataSource jrb=new JRBeanCollectionDataSource(users);
             JasperPrint jasperPrint 
=
                    JasperFillManager.fillReport(Test.
class.getResourceAsStream("heting.jasper"), parameters, jrb
                    );

           JRHtmlExporter exporter = new JRHtmlExporter();
        exporter.setParameter(JRHtmlExporterParameter.OUTPUT_FILE_NAME,ls_reportname
+".htm");
        exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, 
"GBK");            
        exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, 
"<div style=\"page-break-after:always\"></div>");
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, response.getOutputStream());
            exporter.exportReport();
EXCEL
JRBeanCollectionDataSource jrb=new JRBeanCollectionDataSource(users);
             JasperPrint jasperPrint 
=
                    JasperFillManager.fillReport(Test.
class.getResourceAsStream("heting.jasper"), parameters, jrb
                    );

           JRHtmlExporter exporter = new JRHtmlExporter(); 
        response.reset();
        response.setContentType(
"application/vnd.ms-excel"); 
        response.setHeader(
"Content-Disposition""attachment;filename=\"" + ls_reportname + ".xls\""); 
        exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); 
        exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE); 
        exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); 
         exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, 
"GBK");
        exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,response.getOutputStream()); 
            exporter.exportReport();

posted @ 2008-10-22 20:10 贺挺 阅读(628) | 评论 (2)编辑 收藏

Servlet: "weblogic.wsee.async.AsyncResponseBean" failed to preload on startup in Web application: "EJBDemoTest". com.sun.xml.ws.model.RuntimeModelerException: The web service defined by the class weblogic.wsee.async.AsyncResponseBean does not contain any valid WebMethods. at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:262) at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:322) at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:188) at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467) at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:510) at weblogic.wsee.jaxws.JAXWSDeployedServlet.getEndpoint(JAXWSDeployedServlet.java:182) at .........
不知道什么错,只是将EJB工程打成jar包导入web程序中,将weblogin.jar包删除(EJB工厂我导入过weblogin.jar),将从ejb工程拷过来的接口和实体类删除了就可以解决
谁知道这个错帮忙下留下足迹

posted @ 2008-10-16 10:23 贺挺 阅读(2791) | 评论 (2)编辑 收藏

在网上百度了下,原来是要指定filter-mapping的dispatcher方式,如下

<filter-mapping> 
    
<filter-name>Struts2</filter-name> 
    
<url-pattern>/*</url-pattern> 
    
<dispatcher>REQUEST</dispatcher> 
    
<dispatcher>FORWARD</dispatcher> 
</filter-mapping> 



同时找到了其他的资源,这里记录下
3、在做上传文件的时候,要在web.xml中增加ActionContextCleanUp这个filter,如果不增加,会发生第一次上传取不到文件的情况

<filter> 
  
<filter-name>struts-cleanup</filter-name> 
  
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> 
  
</filter> 
  
<filter-mapping> 
    
<filter-name>struts-cleanup</filter-name> 
    
<url-pattern>/*</url-pattern> 
  
</filter-mapping> 


按照Struts2的API,filter的顺序是
struts-cleanup filter
SiteMesh filter
FilterDispatcher

posted @ 2008-10-15 09:05 贺挺 阅读(544) | 评论 (0)编辑 收藏

做ejb3.0的Demo的时候出现的一个反常错误,错误提示如下:
javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: ejb.facade.IFacade (no security manager: RMI class loader disabled)]
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:786)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
 at javax.naming.InitialContext.lookup(Unknown Source)
 at make.Test.main(Test.java:29)
Caused by: java.lang.ClassNotFoundException: ejb.facade.IFacade (no security manager: RMI class loader disabled)
 at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
 at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
 at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
 at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
 at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
 at java.io.ObjectInputStream.readClassDesc(Unknown Source)
 at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
 at java.io.ObjectInputStream.readObject0(Unknown Source)
 at java.io.ObjectInputStream.readObject(Unknown Source)
 at java.rmi.MarshalledObject.get(Unknown Source)
 at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
 at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
 ... 3 more

这个错误郁闷了我很久原来是 我从服务器拷贝出来的接口和实体类到客户端的时候他们在客户端的包名与服务端所在的包名不一致是造成的, 服务端与客户端jar必须完全一致。否则造成客户端访问时,客户端须先从服务端下载,报安全许可异常。记下这个错误防止以后在做错了
posted @ 2008-09-30 10:47 贺挺 阅读(11541) | 评论 (0)编辑 收藏

仅列出标题
共4页: 上一页 1 2 3 4