Posts

Showing posts from February, 2011

RTP - Padding

It is possible that RTP packets contains padding bytes at the end of the payload.
If the padding field at the RTP header is set to 1, it means that padding existing in the packet. The last byte of the packet denote the number of padding bytes should be ignored.
The value include itself. So, if the last byte is a value of 9, it means that the last 9 bytes of the RTP packets are padding.
Some reasons to have padding are
1. The payload are some encrypted data with certain fixed block size 2. Carrying several RTP packets in a lower layer protocol data unit
See: http://www.ietf.org/rfc/rfc3550.txt Section 5.1

Tomcat - JSP Precompilation

Image
JSP is usually compiled during runtime by Java server. Some disadvantages are
1. If you JSP page is large, it will take time to compile at runtime. If that is the first hit, the user will have to wait before the page is served to the user. This is a performance bottlenect.
2. Although the current IDE, such as Eclipse, provide JSP syntax check, you may still run into the situation whereby runtime error occurs due to JSP runtime compilation issues.
To overcome these 2 issues, you can precompile your JSP page before putting them into the server. Tomcat come with JSP precompilation tools for your usage.
The following steps provide information on how to perform JSP precompilation
1. Make sure you have your Tomcat server installed. Or, you need the jar files from tomcat/bin and tomcat/lib, as well as tomcat/bin/catalina-tasks.xml. catalina-tasks.xml is a helper file for loading Catalina ant task for you, ie, jasper task.
2. Make sure you have Apache Ant installed
3. Add the following build script…

Tomcat - IOException while loading persisted sessions

Tomcat save server state when shutdown. Thus, improper shutdown and save state may cause the following error when you start your tomcat server
Feb 21, 2011 6:01:18 PM org.apache.catalina.session.StandardManager doLoad SEVERE: IOException while loading persisted sessions: java.io.EOFException java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
To solve this issue, all you need is to delete the content in the your_tomcat/work directory and restart your server.
Basically, tomcat is trying to look for and read in SESSION.ser. In general, the work directory is working directory for tomcat which reside the JSP and their resulting compiled class files.

MS Virtual PC - Recover Missing Console

Image
For some reason, if you MS Virtual PC console is missing after you double click the icon, and, all you can see is the tray icon for Virtual PC, this entry may help you.
It is highly possible that you have previously used a dual monitor and you have drag your Virtual PC console to the external monitor. Whenever Virtual PC shuts down, it will save its last state, inclusive the X,Y coordinate of the console. The following will fix it
For XP, goes to C:\Documents and Settings\\Application Data\Microsoft\Virtual PC
For Vista or Win7, goes to C:\User\\appdata\roaming\Microsoft\Virtual PC
Look for a Options.xml. In the xml, look for the following


As you can see, left_position and top_position is at a ridiculous coordinates. Reset these 2 values to 0. Also, set visible to true. These setting will make your Virtual PC console reappears at the top left corner of your primary screen

Ant - Creating SVN Ant Task

Image
You can perform SVN checkout/update via Ant task. Follow these steps
1. Go to http://subclipse.tigris.org/svnant.html and download the latest svnant-x.x.x.zip
2. Extract svnant.jar, svnClientAdaptor.jar, svnjavahl.jar and svnkit.jar from the zip file and put them into your classpath
3. Create a ant properties file that contains your svn classpath setting and put it at the same level as your build.xml. Below is an example where svnant jar files are located at lib folder.

4. Put the following at your build.xml

FeedBurner - How to setup Blogspot feed to Twitter via FeedBurner

Image
Thanks to my friend, HJ. I am able to dump TwitterFeed and use FeedBurner.
TwitterFeed has been failing for me and it only works manually. So, I decided to try on FeedBurner. Below are the critical steps to set up FeedBurner to redirect your post to twitter
1. Go to http://feedburner.google.com and enter your blog RSS feed in the text field. Then, just follow the wizard


2. Click on Publicize tab after the wizard setup. Create a twitter account linkage via Add a Twitter account. Click save at the bottom

3. Click on Edit Feed Detail link, look at the feed address and copy it down

4. Go to your Blogspot setting, click on Site Feed tab. Enter your FeedBurner's feed URL at Post Feed Redirect URL. Click save.

Now, you can try posting a blog entry at your blogspot site. It should be reflected in your twitter.

Ant - If and Unless

Image
Apache Ant support condition for target tag and they are if and unless

Above show an example of unless and if usage on target task. You may ask, when to use it? You can phase it as follow with the above example
if -> the update target will ONLY be performed if should.update variable is true
That is, if should.update is defined by either as property tag or as argument input -Dshould.update="true", the update target will be called
unless -> the update target will ALWAYS be performed unless shouldnot.update is true

That is, if shouldnot.update is defined by either as property tag or as argument input -Dshouldnot.update="true", the update target will be called
if and unless are extremely useful to control when to perform the target task.
See: http://ant.apache.org/manual/targets.html

SVN Commands

SVN is a version tools for collaboration development. For Window, you can use TortoiseSVN with GUI interface. For Linux, it is more common to use commands. Below are some commonly used commands. The bold header are the actual command.
svn --help
Provide help access to all commands. For example, svn --help co will give you help on check out command
svn add file.txt or svn add dir
Add a file or the whole directory to the repository. Note that, adding is not equal to check in.
svn co URL folder
Checkout the file from repository from the given URL. To checkout, I recommend the following steps
1. Create a folder, ie, myFolder 2. Navigate to the folder 3 Type svn co http://your_svn_url .
This will help you check out the latest revision of your repository files into your current folder
If you want to checkout a certain revision of the file, use
svn co -r revisionNum http://your_svn_url
svn cleanup
It will help to cleanup your repository and release any holding lock
svn ci filename or svn ci dir
Commit the…

Interprocess Communication

Interprocess communication (IPC) often occurs between processes and threads. Since multiple processes and threads are accessing shared data and communication with one another, it is important to have a synchronized way to perform such action. This entry is to provide some information about IPC.
Race Condition
Most of the time, IPC requires access to shared data. Race condition occurs when 2 or more processes/threads try to read or write onto the shared data and the outcome of the shared data is depends on who runs precisely when. The outcome is usually indeterministic. For example, 2 processes trying to write to a shared variable. Process A update the X=5, and before Process A managed to use the variable for further calculation, it is being context switched. Now, Process B is allow to update X=6 and carry on with its calculation. When Process A allows to continue, it will see X=6 and the calculation for Process A is wrong.
Critical Section
Race condition bring in the idea of critical sect…

Jython - Simple Setup and Example

Jython (http://www.jython.org/) is a Python for Java project. It is useful for people who want to run Python code in JVM.
Here is to teach you some simple set up.
1. Make sure you download latest Jython at http://www.jython.org/downloads.html. When I post this, the latest version is 2.5.3.RC3
2. The 2 most important file in the download is jython.jar and the Lib folder. jython.jar only provide a small implementation of Python functions, seehttp://www.jython.org/javadoc/index.html. Thus, you have to include the provided Lib folder. As long as the Lib folder exist along jython.jar, you can import the provided Python libraries. For example, "from re import *" to import Python regular expression library.
3. Write your own Python code with .py extension
4. Then, you can run this Python code with Java by calling
java -cp "jython.jar" org.python.util.jython your_python_code.py

Ant - OS specific Copy

Image
Sometime, when you work with Apache Ant, you may want to do OS specific copy. For example, only copy .dll in Windows OS and .so in Linux OS.
You can do the following