Tip Bank

DevX - Software Development Resource

Encode and Decode URLs Using UTF-8

This tip shows you how to encode and decode your URLs using the UTF-8 character encoding: import java.net.*;public class URL_Encoder_Decoder{ public static void main(String[] args){ String url = “@sir de

DevX - Software Development Resource

Calling a SOCKS Proxy Server from Java

This tip shows you how to call a SOCKS proxy server from Java code using the Socket class: SocketAddress addr=new InetSocketAddress(?socks_server_proxy?, socks_port);Proxy proxy=new Proxy(Proxy.Type.SOCKS,addr);Socket socket=new Socket(proxy);InetSocketAddress final_addr=new InetSocketAddress(?final_server?, final_port);socket.connect(final_addr);?

DevX - Software Development Resource

Upload Large Files

By default, ASP.NET doesn’t allow you to upload files bigger than 4MB to the server. You can fix this by overriding the default value of 4MB in the web.config file.

DevX - Software Development Resource

Controlling Checkboxes in MFC

Here’s how to check, uncheck, enable, and disable a checkbox in MFC: CButton* pBtn = (CButton*) GetDlgItem(IDC_SETUP_AM); pBtn-&gtSetCheck(0);// uncheck it CButton* pBtn = (CButton*) GetDlgItem(IDC_SETUP_AM); pBtn->SetCheck(1);// check it CButton* pBtn

DevX - Software Development Resource

Authenticate to a Proxy Server

To provide a user’s password to a proxy server, use the following code: URLConnection URLcon=null;URLcon = url.openConnection();byte[] x=”name:password”.getBytes();//coding in Base64String s = new sun.misc.BASE64Encoder().encode(x); URLcon.setRequestProperty( “Proxy-Authorization”,s);

DevX - Software Development Resource

Problem with Parsing Date in Different Regions

Regional settings, especially dates, are always a problem in code. For example, suppose the product is developed in U.S. and deployed in UK. Users entering dates in UK format would

DevX - Software Development Resource

Work with SSL/LDAP Using Java

Most applications nowadays authenticate through LDAP (directory service). To set this up, first register the SSL certificate using the keytool utility, as shown below: Register ssl certificate using keytool:keytool -import