<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>[MeIsProgrammer] &#187; Programming</title>
	<atom:link href="http://just-thor.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://just-thor.com</link>
	<description>all play and no work makes me a dull boy</description>
	<lastBuildDate>Sat, 03 Jul 2010 18:28:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Implement Index controller in Spring Roo</title>
		<link>http://just-thor.com/2010/06/28/implement-index-controller-in-spring-roo/</link>
		<comments>http://just-thor.com/2010/06/28/implement-index-controller-in-spring-roo/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 08:01:05 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Roo]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=144</guid>
		<description><![CDATA[Recently been using Spring roo to produce a rapid prototype. I must say that Spring roo is a very good framework, although still lacking of some features but the potentials [...]]]></description>
			<content:encoded><![CDATA[<p>Recently been using Spring roo to produce a rapid prototype. I must say that Spring roo is a very good framework, although still lacking of some features but the potentials are there.</p>
<p>When you start a new Spring roo project, the default page will be &#8220;index.jspx&#8221;, what if we want to implement a controller to it?</p>
<p>First of all, locate the webmvc-config.xml in your project folder. Find and remove the following line<br />
<code>&amp;lt;mvc:view-controller path=&quot;/index&quot;/&amp;gt;</code></p>
<p>Then, create a Java class file in the source folder, in my case, will be the web folder. Let&#8217;s call it IndexController<br />
<pre><pre class="brush: java">
package com.justthor.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@RequestMapping(&quot;/&quot;)
@Controller
public class IndexController {
&nbsp;&nbsp;@RequestMapping(value = &quot;/index&quot;, method = RequestMethod.GET)
&nbsp;&nbsp;public String index(ModelMap modelMap) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Implement logic here...*/
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &quot;index&quot;;
&nbsp;&nbsp;}
}</pre></pre><br />
That&#8217;s it. To test it, you can implement a logger in your controller. Its quite useful if we want to load some data on the index page.</p>
<p>Happy coding <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2010/06/28/implement-index-controller-in-spring-roo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scala reading content from the Web</title>
		<link>http://just-thor.com/2009/10/16/scala-reading-content-from-the-web/</link>
		<comments>http://just-thor.com/2009/10/16/scala-reading-content-from-the-web/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 10:54:03 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=84</guid>
		<description><![CDATA[I use scala.io.Source in my previous post, and now I am going to show another usage of this util. Let&#8217;s write a simple RSS feed parser that reads feed from [...]]]></description>
			<content:encoded><![CDATA[<p>I use scala.io.Source in my previous <a href="http://just-thor.com/2009/10/01/file-reading-in-java-and-scala/">post</a>, and now I am going to show another usage of this util. Let&#8217;s write a simple RSS feed parser that reads feed from my website and parse it.</p>
<p>Here&#8217;s the code of it.</p>
<p><pre><pre class="brush: scala">
package com.justthor.reader

import scala.io.Source
import scala.xml._

object SimpleFeedReader {
&nbsp;&nbsp;def main(args : Array[String]) : Unit = {
&nbsp;&nbsp;&nbsp;&nbsp;val url = &quot;http://just-thor.com/feed/&quot;
&nbsp;&nbsp;&nbsp;&nbsp;val data = XML.loadString( Source.fromURL(url).mkString )
&nbsp;&nbsp;&nbsp;&nbsp;data \ &quot;channel&quot; \ &quot;item&quot; foreach(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a =&gt; println((a \ &quot;title&quot; text) + &quot; == &quot;&nbsp;&nbsp;+ (a \ &quot;link&quot; text))
&nbsp;&nbsp;&nbsp;&nbsp;)
&nbsp;&nbsp;}
}
</pre></pre></p>
<p>Ok,let&#8217;s go thru the code line by line.</p>
<p>At line 09, again we use Source to load content from url,by calling the method <strong>fromURL</strong>(quite obvious,right?).The <strong>mkString </strong>will create a String out of the content. Then, we use <strong>XML.loadString</strong> to parse the String into an XML object. </p>
<p>At line 10, we traverse the XML object with something like XQuery.<br />
The RSS xml format is something like this<br />
<pre><pre class="brush: xml">
&lt;channel&gt;
&lt;link&gt;...&lt;/link&gt;
&lt;description&gt;...&lt;/description&gt;
&lt;!-- item 1--&gt;
&lt;item&gt;
&nbsp;&nbsp;&lt;title&gt;&lt;/title&gt;
&nbsp;&nbsp;&lt;link&gt;&lt;/link&gt;
&lt;/item&gt;
&lt;!-- item 2--&gt;
&lt;item&gt;
&nbsp;&nbsp;&lt;title&gt;&lt;/title&gt;
&nbsp;&nbsp;&lt;link&gt;&lt;/link&gt;
&lt;/item&gt;
&lt;!-- and the rest goes here --&gt;
&lt;/channel&gt;
</pre></pre></p>
<p>So when we write <pre class="brush: scala">data \ &quot;channel&quot; \ &quot;item&quot;</pre>, we mean traverse to channel node, then item node of it.It will return a collection of item nodes, and then we loop it. At line 11, we will print the text within the title node and the link node.</p>
<p>Here&#8217;s the output of the result<br />
<pre><pre class="brush: text">
File Reading in Java and Scala == http://just-thor.com/2009/10/01/file-reading-in-java-and-scala/
PHP communicate with Java using JSON – Unicode Version == http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/
Scala And JDBC == http://just-thor.com/2009/09/27/scala-and-jdbc/
A mistake or fate? == http://just-thor.com/2009/09/17/a-mistake-or-fate/
Women are weird == http://just-thor.com/2009/09/13/women-are-weird/
20 must visit sites for Java developer == http://just-thor.com/2009/09/12/20-must-visit-sites-for-java-developer/
Why do I practice pair programming? == http://just-thor.com/2009/09/08/why-do-i-practice-pair-programming/
Installing Scala on Windows == http://just-thor.com/2009/09/02/installing-scala-on-window/
Logging for different requested URI in Apache HTTP Server == http://just-thor.com/2009/09/01/logging-for-different-requested-uri-in-apache-http-server/
Say hello to Java and Scala == http://just-thor.com/2009/08/30/say-hello-to-java-and-scala/
</pre></pre></p>
<p>And now we have a very simple yet functional RSS parser.</p>
<p>Happy coding, <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/10/16/scala-reading-content-from-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP communicate with Java using JSON &#8211; Unicode Version</title>
		<link>http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/</link>
		<comments>http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 12:30:13 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=71</guid>
		<description><![CDATA[JSON is one of the most popular message exchange format nowadays used in web application.Most of the time,we used JSON as a communication message format between Javascript and Server side [...]]]></description>
			<content:encoded><![CDATA[<p>JSON is one of the most popular message exchange format nowadays used in web application.Most of the time,we used JSON as a communication message format between Javascript and Server side language,such as PHP.We can also use it to exchange messages between different languages.</p>
<p>For instance,we want to store a PHP array in database and later to be processed by Java,we can do something like</p>
<p><pre><pre class="brush: php">
$aValue = array(&quot;key1&quot;=&amp;gt;&quot;value1&quot;,&quot;key2&quot;=&amp;gt;&quot;value2&quot;);
$sEncodedValue = json_encode($aValue)
//we will get something like {&quot;key1&quot;:&quot;value1&quot;,&quot;key2&quot;:&quot;value2&quot;}
//and then, we store the value to db
</pre></pre></p>
<p>On the other hand,we use Java  to read it and decode it.</p>
<p><pre><pre class="brush: java">
//read from db and got the resultset,assuming we are using JDBC
while (rs.next()){
String rawValue = rs.getString(&quot;encodedValue&quot;);
// since we encoded an associative array,it will be translated to a Java Map object instance.
// we are using JSON-lib for JSON parsing the following example
JSONObject json = JSONObject.fromObject(jsonString);
Map decodedValue = (Map) JSONObject.toBean(json, Map.class);
String value1 = decodedValue.get(&quot;key1&quot;);
}
</pre></pre></p>
<p>What if we are trying to store unicode value using JSON format in PHP?<br />
For example,</p>
<p><pre><pre class="brush: php">
$aValue = array(&quot;key1&quot;=&amp;gt;&quot;你好吗&quot;,&quot;key2&quot;=&amp;gt;&quot;value2&quot;);
$sEncodedValue = json_encode($aValue);
//This is what we get after encoded
//{&quot;key1&quot;:&quot;\u4f60\u597d\u5417&quot;,&quot;key2&quot;:&quot;value2&quot;}
</pre></pre></p>
<p>If you decoded it back to Java,key1 value will return &#8220;u4f60u597du5417&#8243; instead.This is so wrong.</p>
<p>How to solve it?<br />
We can use <b>mb_convert_encoding</b> function in PHP.<br />
Let&#8217;s make some changes to our code.</p>
<p><pre><pre class="brush: php">
$aValue = array(&quot;key1&quot;=&amp;gt;mb_convert_encoding(&quot;你好吗&quot;, &quot;UTF-8&quot;),&quot;key2&quot;=&amp;gt;&quot;value2&quot;);
$sEncodedValue = json_encode($aValue);
</pre></pre></p>
<p>By doing so,values are stored in database in unicode format,and you can decode it back in Java.</p>
<p>Happy coding. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>20 must visit sites for Java developer</title>
		<link>http://just-thor.com/2009/09/12/20-must-visit-sites-for-java-developer/</link>
		<comments>http://just-thor.com/2009/09/12/20-must-visit-sites-for-java-developer/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 03:06:56 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=39</guid>
		<description><![CDATA[Here is a list of urls I visit to get information on Java. 1.http://www.javaalmanac.com 2.http://www.onjava.com 3.http://java.sun.com 4.http://www.developer.com/java 5.http://www.java.net 6.http://www.builder.com 7.http://www.ibm.com/developerworks/java 8.http://www.javaworld.com 9.http://www.devx.com/java 10.http://www.fawcette.com/javapro 11.http://www.sys-con.com/java 12.http://www.javadesktop.org 13.http://www.theserverside.com 14.http://www.jars.com 15.http://www.jguru.com 16.http://www.javaranch.com 17.http://www.ibiblio.org/javafaq/javafaq.html [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a list of urls I visit to get information on Java.</p>
<p>1.http://www.javaalmanac.com</p>
<p>2.http://www.onjava.com</p>
<p>3.http://java.sun.com</p>
<p>4.http://www.developer.com/java</p>
<p>5.http://www.java.net</p>
<p>6.http://www.builder.com</p>
<p>7.http://www.ibm.com/developerworks/java</p>
<p>8.http://www.javaworld.com</p>
<p>9.http://www.devx.com/java</p>
<p>10.http://www.fawcette.com/javapro</p>
<p>11.http://www.sys-con.com/java</p>
<p>12.http://www.javadesktop.org</p>
<p>13.http://www.theserverside.com</p>
<p>14.http://www.jars.com</p>
<p>15.http://www.jguru.com</p>
<p>16.http://www.javaranch.com</p>
<p>17.http://www.ibiblio.org/javafaq/javafaq.html</p>
<p>18.http://java.sun.com/docs/books/tutorial/</p>
<p>19.http://www.javablogs.com</p>
<p>20.http://java.about.com/</p>
<p>Happy coding. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/09/12/20-must-visit-sites-for-java-developer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why do I practice pair programming?</title>
		<link>http://just-thor.com/2009/09/08/why-do-i-practice-pair-programming/</link>
		<comments>http://just-thor.com/2009/09/08/why-do-i-practice-pair-programming/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 09:32:33 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Agile]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=50</guid>
		<description><![CDATA[I used to practice pair programming in my previous job, when leading a team of 8 people and some of them are junior. The main reason I practiced pair programming [...]]]></description>
			<content:encoded><![CDATA[<p>I used to practice pair programming in my previous job, when leading a team of 8 people and some of them are junior. The main reason I practiced pair programming is that I found that the junior developers were implementing the things wrongly,eg writing really ugly code, strange work flow design etc. So I decided to pair them up, including myself, to improve the code qualities.</p>
<p>So I started off with myself, everyday I was pairing with one of them. The reason why I didn&#8217;t straightaway implementing it through out the team was because by then I wasn&#8217;t so sure about this practice would actually helps to increase the productivity and quality like what stated in any XP books.</p>
<p>At first, they were thinking that I am going to help them with their work. I was like,&#8221;Hell no I am not!I am not going to code or do your work for you. Instead, I am going to do your work with you. OK, let&#8217;s start by going through the design.&#8221;</p>
<p>Pairing up is great, I get to understand their design and discuss with them, and also it&#8217;s a good chance for me to spreading out knowledge like how to format the code, how do we normally name it etc. End of the sprint, we talked about the pairing process, and turned out everyone loves it. From that sprint onwards, we started practicing pair programming.</p>
<p>You might be curious, how come when 2 person using one workstation to develop will actually increase productivity? Isn&#8217;t that 2 people can do more work? Let&#8217;s elaborate the advantages one by one.</p>
<ul>
<li>Increase productivity &#8211; If you enjoy reading news, browsing forums, writing blogs, chatting with some chicks in front of your colleague, this rules probably doesn&#8217;t apply to you. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Code quality &#8211; There is always another person sits beside you and look at what you have code. This actually reduce the chances someone accidentally injected buggy code into the system.</li>
<li>Better design &#8211; You can always discuss with your partner about your design and get some ideas on how to improve it.</li>
<li>Reduce your workload &#8211; There are always other people who knows the design and the code when you pairing up with them. Therefore, when you going off on a vacation, you won&#8217;t have to worry your office will call you up and telling you that the website is down.</li>
</ul>
<p>So, shall you practice pair programming? It depends on the team culture. If the some members are trying to hide their skills or expect his partner to do all the work, then this might not be a suitable practice. In my opinion, agile development practices are always depends on human who practice it. It can only identify human problem, but never expect it will solve it for you.</p>
<p>Happy coding. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/09/08/why-do-i-practice-pair-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Say hello to Java and Scala</title>
		<link>http://just-thor.com/2009/08/30/say-hello-to-java-and-scala/</link>
		<comments>http://just-thor.com/2009/08/30/say-hello-to-java-and-scala/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 14:09:39 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=35</guid>
		<description><![CDATA[Let&#8217;s write a legendary &#8220;Hello world&#8221; program in both Java and Scala language. This is how we do in Java. public class Hello { public static void main(String[] args) { [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s write a legendary &#8220;Hello world&#8221; program in both Java and Scala language.</p>
<p>This is how we do in Java.<br />
<pre><pre class="brush: java">
public class Hello {
 public static void main(String[] args) {
&nbsp;&nbsp;System.out.println(&quot;Hello world&quot;);
 }
}</pre></pre><br />
and this is how we do in Scala<br />
<pre><pre class="brush: scala">object Hello {
 def main(args : Array[String]) = println(&quot;Hello world&quot;)
}</pre></pre><br />
So when you execute both code,they actually return the same result.What about printing arguments instead?</p>
<p>Java style<br />
<pre><pre class="brush: java">public class HelloArgument {
 public static void main(String[] args) {
&nbsp;&nbsp;for (String arg : args) {
&nbsp;&nbsp; System.out.println(&quot;Hello, &quot; + arg);
&nbsp;&nbsp;}
 }
}</pre></pre></p>
<p>Scala style<br />
<pre><pre class="brush: scala">object HelloArgument {
 def main(args : Array[String]) = args.foreach(arg =&amp;gt; println(&quot;Hello, &quot; + arg))
}</pre></pre></p>
<p>Pretty impressive,huh?Comparing Java,we are actually writing less and more readable code in Scala,and the results are the same.</p>
<p>Happy coding. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/08/30/say-hello-to-java-and-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript manipulating multiple cookie values in one cookie</title>
		<link>http://just-thor.com/2009/08/28/javascript-manipulating-multiple-cookie-values-in-one-cookie/</link>
		<comments>http://just-thor.com/2009/08/28/javascript-manipulating-multiple-cookie-values-in-one-cookie/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 06:00:37 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=25</guid>
		<description><![CDATA[Sometimes,its convenient to store values in cookies and retrieve it later.But,when dealing with different browsers,you may have problems as different browser may support different numbers of cookies.For example, IE can [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes,its convenient to store values in cookies and retrieve it later.But,when dealing with different browsers,you may have problems as different browser may support different numbers of cookies.For example, IE can only <a href="http://support.microsoft.com/kb/306070" target="_blank">support up to 20 cookies for one single domain</a>. Therefore, we may need to compact our cookies into one instead of more.</p>
<p>How do we do that in Javascript?</p>
<p>Lets say originally we have like 3 cookies value storing for the same domain.<br />
<pre><pre class="brush: javascript">document.cookie = &quot;cookie1=val1;path=/;domain=just-thor.com&quot;
document.cookie = &quot;cookie2=val2;path=/;domain=just-thor.com&quot;
document.cookie = &quot;cookie3=val3;path=/;domain=just-thor.com&quot;</pre></pre><br />
By using javascript, first of all we store all 3 values into 1,and separate it by a separator.<br />
<pre class="brush: javascript">document.cookie = &quot;allcookies=cookie1=val1|cookie2=val2|cookie3=val3;path=/;domain=just-thor.com&quot;</pre><br />
Instead directly reading from cookies,first we translate our cookies value into array.<br />
<pre><pre class="brush: javascript">var cookieArray = translateCookiesToArray(new Array(), &quot;allcookies&quot;);
// you can append more items into the array by calling
// cookieArray = translateCookiesToArray(cookieArray, &quot;anotherCookiesCollection&quot;);

function translateCookiesToArray(result, key) {
 rawString = getCookieValue(key);
 if (rawString != null) {
 tokenizedString = rawString.split(&quot;|&quot;);

 for (i=0;i&amp;lt;tokenizedString.length;i++){
 innerArray = tokenizedString[i].split(&quot;=&quot;);
 result[innerArray[0]] = innerArray[1];
 }
 }

 return result;
}</pre></pre><br />
To get value for cookie1,simply type<br />
<pre class="brush: javascript">cookieArray[&quot;cookie1&quot;]</pre><br />
You can always refactor it by globalize the separator variable and the way you access cookieArray. Refer to the code below.</p>
<p>Here&#8217;s the complete code<br />
<pre><pre class="brush: javascript">var cookieArray = translateCookiesToArray(new Array(), &quot;allcookies&quot;);

function translateCookiesToArray(result, key) {
 rawString = getRawCookieValue(key);
 if (rawString != null) {
&nbsp;&nbsp;tokenizedString = rawString.split(&quot;|&quot;);

&nbsp;&nbsp;for (i=0;i&amp;lt;tokenizedString.length;i++){
&nbsp;&nbsp; innerArray = tokenizedString[i].split(&quot;=&quot;);
&nbsp;&nbsp; result[innerArray[0]] = innerArray[1];
&nbsp;&nbsp;}
 }

 return result;
}

function getRawCookieValue(name)
{
 var arg = name + &quot;=&quot;;
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i &amp;lt; clen) {
&nbsp;&nbsp;var j = i + alen;
&nbsp;&nbsp;if (document.cookie.substring(i, j) == arg) {
&nbsp;&nbsp; return getCookieByOffset(j);
&nbsp;&nbsp;}
&nbsp;&nbsp;i = document.cookie.indexOf(&quot; &quot;, i) + 1;
&nbsp;&nbsp;if (i == 0) break;
 }
 return null;
}

function getCookieByOffset (offset)
{
 var endstr = document.cookie.indexOf (&quot;;&quot;, offset);
 if (endstr == -1) {
&nbsp;&nbsp;endstr = document.cookie.length;
 }
 return unescape(document.cookie.substring(offset, endstr));
}
function getCookieValue (name)
{
 value = cookieArray[name];
 if (typeof value == &quot;undefined&quot;) {
&nbsp;&nbsp;value = null;
 }
 return value;
}
//retrieving value
var val1 = getCookieValue(&quot;cookie1&quot;);</pre></pre><br />
Feel free to leave any comment.</p>
<p>Happy coding</p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/08/28/javascript-manipulating-multiple-cookie-values-in-one-cookie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
