Recent Notes

Displaying notes 11 - 20
Created by meiu on July 22, 2010 20:16:59    Last update: July 22, 2010 20:17:28
By this thread on OTN, JRockit mission control and JRockit real time are exactly the same! JRockit Mission Control x JRockit Real Time But Oracle is offering downloads with two separate links with no explanation what so ever?!
Created by voodoo on July 22, 2010 17:00:54    Last update: July 22, 2010 17:01:44
Use: yum install gcc-c++ " yum install g++ " does not work.
Created by Fang on July 22, 2010 16:52:16    Last update: July 22, 2010 16:53:26
JSTL XML tags does not work with XML namespace. Take this JSP: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%> <html> <head> <title>JSTL XML Namespace</title> </head> <body> <!-- without namespace --> <x:parse var="newsWithoutNamespace"> <News> <item id="1"> <header>I made this up</header> </item> <item id="2"> <header>This is a true story</header> </item> </News> </x:parse> <h2>Today's news without XML Namespace</h2> <ul> <x:forEach var="story" select="$newsWithoutNamespace/News/item"> <li><x:out select="header"/></li> </x:forEach> </ul> <!-- Same XML with namespace --> <x:parse var="newsWithNamespace"> <News xmlns="http://the.big.rumor.mill/feed"> <item id="1"> <header>I made this up</header> </item> <item id="2"> <header>This is a true story</header> </item> </News> </x:parse> <h2>Today's news with XML Namespace</h2> <ul> <x:forEach var="story" select="$newsWithNamespace/News/item"> <li><x:out select="header"/></li> </x:forEach> </ul> </body> </html> The second list will be empty due to the namespace declaration. In fact, the JSR change log clearly states: JSTL ...
Created by Dr. Xi on July 21, 2010 22:14:53
This is a Java program to test XPATH expressions with namespace option. It's been tested with JDK1.6. import java.io.FileInputStream; import java.util.Iterator; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.*; import javax.xml.xpath.*; import javax.xml.namespace.NamespaceContext; import org.w3c.dom.*; public class XPathExample { public static void main(String[] args) throws Exception { if (args.length < 2) { usage(); return; } String inputFile = args[0]; String xPathStr = args[1]; // optional namespace spec: xmlns:prefix:URI String nsPrefix = null; String nsUri = null; if ((args.length >= 3) && args[2].startsWith("xmlns:")) { String[] nsDef = args[2].substring("xmlns:".length()).split("="); if (nsDef.length == 2) { nsPrefix = nsDef[0]; nsUri = nsDef[1]; } } // Parse XML to DOM DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); Document doc = dbFactory .newDocumentBuilder() .parse(new FileInputStream(inputFile)); // Find nodes by XPATH XPathFactory xpFactory = XPathFactory.newInstance(); XPath xpath = ...
Created by voodoo on July 21, 2010 16:10:47
Google news RSS does not like curl: C:\> curl --dump-header - -o NUL http://news.google.com/?output=rss % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/1.1 403 Forbidden Content-Type: text/html; charset=UTF-8 Set-Cookie: PREF=ID=d25a6334e29f8a90:TM=1279728231:LM=1279728231:S=cXfnyhgZ8VIZuq13; expires=Fri, 20-Jul-2012 16:03:51 GMT; path=/; domain=.google.com X-Content-Type-Options: nosniff Date: Wed, 21 Jul 2010 16:03:51 GMT Server: NFE/1.0 Content-Length: 1383 X-XSS-Protection: 1; mode=block 100 1383 100 1383 0 0 8135 0 --:--:-- --:--:-- --:--:-- 23440 Switch the agent to HotJava with the -A option: C:\> curl -A "HotJava/1.1.2 FCS" --dump-header - -o google-news.xmn http://news.google.com/?output=rss % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 ...
Created by Dr. Xi on July 19, 2010 21:58:34    Last update: July 23, 2010 21:37:23
Parsing XML in Java is really simple: import java.io.*; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class DOMParserExample { public static void main(String[] args) throws Exception { if (args.length < 1) { System.out.println("Usage: java DOMParserExample <xmlFileName>"); return; } DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); InputStream in = new FileInputStream(args[0]); Document doc = factory.newDocumentBuilder().parse(in); in.close(); System.out.println("DOM doc: " + doc); System.out.println("DOM doc class: " + doc.getClass().getName()); } } The parser implementation details are hidden behind the JAXP API. In case you want to know which parser implementation is used, this is what the JavaDoc for DocumentBuilderFactory.newInstance says: Use the javax.xml.parsers.DocumentBuilderFactory system property. Use the properties file " lib/jaxp.properties " in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the ...
Created by Fang on July 17, 2010 03:16:53    Last update: July 17, 2010 03:18:25
This error happens when the ordering of elements in web.xml is not correct. For example, in a <servlet> declaration, <servlet-name> should come before <servlet-class> . If you switch the order of <servlet-name> and <servlet-class> , you'll get this error. This was my stack trace in JBoss when I declared <load-on-startup> before <init-param> for a servlet: DEPLOYMENTS IN ERROR: Deployment "vfszip:/C:/local/jboss-5.1.0.GA/server/default/deploy/jstl-demo.wa r/" is in error due to the following reason(s): org.xml.sax.SAXException: cvc-co mplex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns /javaee":security-role-ref}' is expected. @ vfszip:/C:/local/jboss-5.1.0.GA/serv er/default/deploy/jstl-demo.war/WEB-INF/web.xml[12,21] at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(Dep loyersImpl.java:993) at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(Dep loyersImpl.java:939) at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainD eployerImpl.java:873) at org.jboss.system.server.profileservice.repository.MainDeployerAdapter .checkComplete(MainDeployerAdapter.java:128) at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDSca nner.java:369) at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScan ner.java:255) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44 1) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java
Created by voodoo on July 15, 2010 22:57:48    Last update: July 15, 2010 22:58:37
Use -xl switch when connecting thru LAN: rdesktop -f -xl remote_host_name One effect of specifying LAN speed being Windows contents are displayed when they are dragged. Full documentation: -x <experience> Changes default bandwidth performance behaviour for RDP5. By default only theming is enabled, and all other options are dis- abled (corresponding to modem (56 Kbps)). Setting experience to b [roadband] enables menu animations and full window dragging. Setting experience to l [an] will also enable the desktop wallpa- per. Setting experience to m [odem] disables all (including themes). Experience can also be a hexidecimal number containing the flags.
Created by voodoo on July 15, 2010 22:43:40    Last update: July 15, 2010 22:45:07
You need to merge this value into the Windows XP registry in order to make ClearType work for a remote desktop: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations] "AllowFontAntiAlias"=dword:00000001 A restart is required for the change to take effect.
Created by voodoo on July 14, 2010 23:37:46
Run gpedit.msc Find Administrative Templates -> Windows Components -> Terminal Services -> Limit Maximum color depth. Right click on "Limit maximum color depth", click "Properties", then select "Client Compatible".
Previous  1 2 3 4 5 6 7 8 9 10 Next