Sunday, February 08, 2015

How to extract audio from youtube and burn it CD format

Step 1) Use torch browser to download youtube. It will extract it to both mp4 (video) and acc (audio) Step 2) Use foobar2000 + Audio CD Writer component of foobar (installed separately) to convert acc to wav. Step 3) Use CdBurnerXP to burn wav into audio cd format.

Wednesday, July 22, 2009

Invoking an external web service using WID from behind the firewall

So, you imported a WSDL (from an external provider) onto your SCA module in WID, you tried invoking it, but you keep getting Connection timed out: no further information
at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(

That's because the machine where the WSDL is being invoked from is behind the firewall.

So, to invoke an external web service from behind a firewall, you need to set your jvm system properties :
1) Open the administrative console. Click Servers ==> Application Servers ==> server ==> Java and Process Management ==> Process Definition ==> Java Virtual Machine ==> Custom Properties

2) Add these into the Generic JVM Arguments

name=http.proxySet value=true
name=http.proxyPort value=8080
name=http.proxyUser value=your_proxy_username_if_required
name=http.proxyPassword value=your_proxy_password_if_required
name=http.nonProxyHosts value=localhost|*

Alternatively, you could add this to the generic JVM arguments of your JVM

-Dhttp.proxySet=true -Dhttp.proxyPort=8080 -Dhttp.proxyUser=yourproxyusername -Dhttp.proxyPassword=yourproxypassword -Dhttp.nonProxyHosts=hostNamesOfMachinesToWhichRequestsWillNotBeSentThroughTheProxyServer

See Configuring additional HTTP transport properties using the JVM custom property panel in the administrative console

Don't forget to set your http.nonProxyHosts. If it is not set, all your http connections will go thru the proxy server, which you don't want to do. You only want your external web service requests to go thru the proxy server, but you want your internal web service requests to not go thru the proxy server.


Wednesday, March 19, 2008

java: An algorithm for converting an array to comma delimited/separated string/value (e.g. csv)

StringBuilder sb = new StringBuilder();

Long[] array = {new Long("1"), new Long("2"), new Long("3")};

for (int i = 0; i < array.length(); i++)
   if (i > 0) 
       sb.append(", ");



//output: 1, 2, 3

Tuesday, March 18, 2008

java: How to convert String array to Long array

String[] numbersString = {"1", "2", "3"};

List list = new ArrayList();

for (int i = 0; i <>
    Long tmp = Long.valueOf(s[i]);
//convert Long ArrayList to Long[] array 
Long[] numbersLong = (Long[])list.toArray(new Long[0]);

Saturday, March 15, 2008

java: How to put checkboxes in DisplayTag using Struts multibox

<display:table name="sessionScope.myFormBean.mySearchResultArrayList" id="myRecord">
<display:column title="Select">
<html:multibox property="selectedItems"
value='<%= (String)(( %>' />


myFormBean is the name of your Form Bean (i.e.

mySearchResultArrayList is a collection getter in your It will hold a collection of your

MyClass will represent each row in your DisplayTag (i.e. Your mySearchResultArrayList will contain many

myRecord represents the reference to the MyClass object.

selectedItems is a String array property in your with a getter/setter. It will hold the values of the selected checkboxes. It will also be the name of the checkbox group in html.

public class MyClass
private String abc;

public void setAbc(String abc)
{ = abc;

private String getAbc( )
return abc;

public class MyFormBean
private String[ ] selectedItems;
private List mySearchResultArrayList;

public void setMySearchResultArrayList(List list)
mySearchResultArrayList = list;
String[] selectedItems = (String[]) mySearchResultArrayList.toArray(new String[0]);

public List get
MySearchResultArrayList( )

public String[ } getSelectedItems( )

public void setSelectedItems(String[ ] selectedItems)
this.selectedItems = selectedItems;

javascript: How to select/deselect checkboxes

This function will select/deselect, tick/untick, check/uncheck all checkboxes belonging to a group. It can be used by a button to toggle a checkbox collection (e.g. Struts multibox in DisplayTag).

function toggle (checkboxes, isSelectAll)
if (checkboxes != null)
for (i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = isSelectAll;

Usage: You can call this function on two buttons:
- select button: onclick="CheckboxUtil.toggle(document.formName.checkboxName, true)"
- deselect button: onclick="CheckboxUtil.toggle(document.formName.checkboxName, false)"

- formName = name of the form.
- checkboxName = name of the checkbox group

Make sure all your checkboxes have the same checkboxName.

java: How to get DisplayTag sorting URL to work in Struts Tiles

Simply put requestURI with blank value onto the DisplayTag attribute.

<display:table name="sessionScope.myForm.searchResult"


java: How to convert a String ArrayList into String array

String[] stringArray = (String[]) stringArrayList.toArray(new String[0]);

java: The difference between the HTML comment <!-- --> and the JSP comment <%-- --%>

The HTML comment will show up in browser view source.

The JSP comment <%-- --%> will not show up in browser view source.

Monday, March 10, 2008

java: Why Log4J's Logger should be declared static final

Declaring Logger to be static final is recommended, particularly for long lived objects such as the Struts Action class

private static final Logger LOGGER = Logger.getLogger(Donkey.class)

The Struts framework creates only one instance of an Action class for all client requests. e.g. FooAction and BarAction will only be created once.
Static means the Logger is not specific to a particular client request, but is shared by all requests.
Final means the Logger will only be instantiated once.

Logger is tread safe because it doesn't hold a state.

Sunday, February 24, 2008

Java: Eclipe's notion of classpath 101

In Eclipse, if you don't specify the build path, your classes by default will be placed in the base classpath of your project module. E.g.

Therefore, your base classpath is C:\workspaces\myproject\myModuleEJB\classes\xxx

Consider two spring config source folders :

testApplicationContext.xml is referring to businessRules.xml e.g.


<bean id="businessRules" init="false" class="">

both testApplicationContext.xml and businessRules.xml are compiled by Eclipse into

therefore, if testApplicationContext.xml wants to refer to businessRules.xml, the testApplicationContext.xml has to refer to the base classpath location of businessRules.xml
ie. /spring/businessRules.xml

java: Spring's Hibernate Template now obsolete as of Hibernate 3.0.1


Also, see
- Spring in Action (2nd ed) page 193

- Beginning Spring 2 page 70