Blog Archives


Yesterday, my boss asked me to write a program demo to get data at other website.His need is: if we use url:http://www.***.com/coord.php?coord=51.00, coord.php page will send a post request to website: http://www.***.com to and get ,print data.

From need, i know i should program a jsp demo, this functions are:

1.JSP page should send a post request to other website

2.JSP page should get response data and echo it.

To realize this need, we can do as follow:

Step 1: Create a jsp file

We can use eclipse to create a jsp file,meanwhile, you should make sure your created jsp file can be executed in your program, which means you should have a tomcat+jdk environment.


Today i open a url by my browser, i find my eclipse show error:java.lang.OutOfMemoryError: PermGen space,which means tomcat use too much memory.Then the web system can not be opened correctly.

To fix this problem is easy, you can search much solutions by google, today i introduce my solution steps.

Step 1: Close your eclipse and edit eclipse.ini

If you have opened window of eclipse, you should close it.

Then you should open eclipse.ini file and edit it.

If you do not know where this file is, you can find it at the install path of your eclipse. For example, paht:D:\Program Files\eclipse is my eclipse install path and eclipse.ini file is in directory of D:\Program Files\eclipse.


MD5 is an encryption algorithm and is be used in many applications. It also have some types, for example, 16-bit,32-bit or 128-bit, In java, if you want to use 32-bit md5 to encrypt string, you can do like this:

Step 1: Create a 32-bit MD5 class in java

In java, a sample source code of  32-bit MD5 class is :


import java.security.MessageDigest;
public class MD5 {
 public static String encryptStr(String s){
 char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
 try {
 byte[] bytes = s.getBytes();
 MessageDigest md = MessageDigest.getInstance("MD5");
 md.update(bytes);
 bytes = md.digest();
 int j = bytes.length;
 char[] chars = new char[j * 2];
 int k = 0;
 for (int i = 0; i < bytes.length; i++) {
 byte b = bytes[i];
 chars[k++] = hexChars[b >>> 4 & 0xf];
 chars[k++] = hexChars[b & 0xf];
 }
 return new String(chars);
 }
 catch (Exception e) {
 return null;
 }
 }

}