<?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>Rochak Chauhan::Unpredictably Exciting &#187; Programming</title>
	<atom:link href="http://rochakchauhan.com/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://rochakchauhan.com/blog</link>
	<description>Know your limits, but never stop trying to exceed them.</description>
	<lastBuildDate>Thu, 03 May 2012 11:48:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>WCAG 2.0 Guidelines</title>
		<link>http://rochakchauhan.com/blog/2011/07/04/wcag-2-0-guidelines/</link>
		<comments>http://rochakchauhan.com/blog/2011/07/04/wcag-2-0-guidelines/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 05:35:24 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Softwares]]></category>
		<category><![CDATA[Tech News]]></category>
		<category><![CDATA[Guidelines]]></category>
		<category><![CDATA[WCAG 2.0]]></category>
		<category><![CDATA[WCAG 2.0 Guidelines]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/?p=1152</guid>
		<description><![CDATA[Perceivable: The perceivable principle is the first principle and it states that the information on a user interface component must be presentable to users in such a way that they can perceive. The principle one gives more importance on the perceivable aspect of the presentation. This principle specifies four aspects: They are as follows:&#160; Text &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2011/07/04/wcag-2-0-guidelines/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<ol>
<li><strong>Perceivable:</strong><br />
The 	perceivable principle is the first principle and it states that the  	information on a user interface component must be presentable to 	 users in such a way that they can perceive. The principle one gives 	 more importance on the perceivable aspect of the presentation. This 	 principle specifies four aspects: They are as follows:&nbsp;</p>
<ol>
<li><strong>Text Alternatives:</strong> Provide text alternatives for  any non-text content so that it can 		be changed into other forms people  need, such as large print, 		braille, speech, symbols or simpler  language.</li>
<li><strong>Time-based Media:</strong> Provide alternatives for time-based media.</li>
<li><strong>Adaptable:</strong> Create content that can be presented in different ways (for example 		simpler layout) without losing information or structure.</li>
<li><strong>Distinguishable:</strong> Make it easier for users to see and hear content including 		separating foreground from background.</li>
</ol>
</li>
<li><strong>Operable</strong> – User interface components and navigation must be operable.<br />
The 	second principle is on the operable nature of the content. The 	 operable principle speaks on four aspects. They are mentioned below.&nbsp;</p>
<ol>
<li><strong>Keyboard Accessible:</strong> Make all functionality available from a keyboard.</li>
<li><strong>Enough Time:</strong> Provide users enough time to read and use content.</li>
<li><strong>Seizures:</strong> Do not design content in a way that is known to cause seizures.</li>
<li><strong>Navigable:</strong> Provide ways to help users navigate, find content, and determine 		where they are.</li>
</ol>
</li>
<li><strong>Understandable:<br />
</strong>The 	Third principle speaks on the understandability of the  content. It 	is stated that the Information and the operation of user  interface 	must be understandable. The understandable principle speaks  about 	three aspects.&nbsp;</p>
<ol>
<li><strong>Readable:</strong> Make text content readable and understandable.</li>
<li><strong>Predictable: </strong>Make 		Web pages appear and operate in predictable ways.</li>
<li><strong>Input Assistance:</strong> Help users avoid and correct mistakes.</li>
</ol>
</li>
<li><strong>Robust:<br />
</strong>This 	is the fourth principle in the WCAG 2.0 recommendation.  This 	principle states that the content must be robust enough that it  can 	be interpreted reliably by a wide variety of user agents, including  	assistive technologies. The robust principle has only one aspect.&nbsp;</p>
<ol>
<li><strong>Compatible:</strong> Maximize compatibility with current and future user agents, 		including assistive technologies.</li>
</ol>
</li>
</ol>
<p>Developing the web contents so as to meet the guidelines specified in the WCAG2.0 makes the content accessible to more audience.</p>
<p>&nbsp;</p>
<p><a href="http://www.w3.org/TR/WCAG20/">&#8230;more about WCAG.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2011/07/04/wcag-2-0-guidelines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Keyword Analyser</title>
		<link>http://rochakchauhan.com/blog/2009/03/09/php-keyword-analyser/</link>
		<comments>http://rochakchauhan.com/blog/2009/03/09/php-keyword-analyser/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 09:07:17 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Free source code]]></category>
		<category><![CDATA[PHP Class]]></category>
		<category><![CDATA[PHP Keyword Analyser]]></category>
		<category><![CDATA[SEO Tool]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/?p=820</guid>
		<description><![CDATA[This can be used to find out how a site ranks in Google for a keyword. It can access Google search pages to perform a search for a given keyword. The class check the first 10 pages of results and check whether any pages of a given site appear in the results. It returns the &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2009/03/09/php-keyword-analyser/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>This can be used to find out how a site ranks in Google for a keyword. It can access Google search pages to perform a search for a given keyword. The class check the first 10 pages of results and check whether any pages of a given site appear in the results.<br />
It returns the first position the given site appears in the result pages.</strong></p>
<p><strong>Demo: </strong></p>
<ul>
<li><a title="Online Demo" href="http://demo.dmwtechnologies.com/PHP/PhpKeywordAnalyser/" target="_blank">http://demo.dmwtechnologies.com/PHP/PhpKeywordAnalyser/</a></li>
</ul>
<p><strong>Download: </strong></p>
<ul>
<li><a title="Ajax Grid" href="http://www.phpclasses.org/browse/package/2828.html" target="_blank">http://www.phpclasses.org/browse/package/5209.html<br />
</a></li>
<li><a title="Ajax Grid" href="http://phpclasses.dmwtechnologies.com/browse/package/2828.html" target="_blank"></a> <a href="http://phpclasses.dmwtechnologies.com/browse/package/5209.html" target="_blank">http://phpclasses.dmwtechnologies.com/browse/package/5209.html</a> (mirror)</li>
</ul>
<p><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2009/03/09/php-keyword-analyser/feed/</wfw:commentRss>
		<slash:comments>542</slash:comments>
		</item>
		<item>
		<title>Rochak.js &#8211; Javascript class of common functions</title>
		<link>http://rochakchauhan.com/blog/2008/10/10/rochakjs-javascript-class-of-common-functions/</link>
		<comments>http://rochakchauhan.com/blog/2008/10/10/rochakjs-javascript-class-of-common-functions/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 13:36:58 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[detect browers]]></category>
		<category><![CDATA[detect chorme]]></category>
		<category><![CDATA[explode]]></category>
		<category><![CDATA[find mouse position]]></category>
		<category><![CDATA[inArray]]></category>
		<category><![CDATA[rochak.js]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[validate email]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2007/10/08/rochakjs-javascript-class-of-common-functions/</guid>
		<description><![CDATA[Rochak.js - Javascript class of common functions <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/10/10/rochakjs-javascript-class-of-common-functions/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This class is a collection of basic and commonly used functions in JavaScript.  I coded this class just to validate a form in one of my sites. But it turned out to be more than helpful. I hope it will be of some help for all the web developers.</p>
<p>If you want a new function added or face any difficulty, feel free to contact me.</p>
<ul>
<li>Initialize:<a title="Rochak.js" href="http://rochakchauhan.com/blog/wp-content/uploads/2007/10/rochak-10.js"></a>
<ul>
<li>Just include it at the very top of all the JavaScript file as:
<pre>&lt;script src="rochak.js" type="text/javascript"&gt;</pre>
</li>
</ul>
</li>
<li>Usage:
<ul>
<li>For example to trim a string:
<pre>rochak.Function_Name(Parameter);    eg:
var str=rochak.trim(str);</pre>
</li>
</ul>
</li>
<li>Complete JavaScript Function List:
<ol>
<li><strong>lTrim(string):</strong>
<ul>
<li>Function to trim all the white spacing from the left side of any string.</li>
</ul>
</li>
<li><strong>rTrim(</strong><strong>string</strong><strong>):</strong>
<ul>
<li>Function to trim all the white spacing from the right side of any string.</li>
</ul>
</li>
<li><strong>trim(</strong><strong>string</strong><strong>):</strong>
<ul>
<li>Function to trim all the white spacing from left and right side of the string.</li>
</ul>
</li>
<li><strong>isValidEmail(</strong><strong>string</strong><strong>):</strong>
<ul>
<li>Function to validate a typical email pattern.</li>
</ul>
</li>
<li><strong>getType(variable_name):</strong>
<ul>
<li>Function to find the type of the variable. A Clone of PHP\&#8217;s &#8220;<strong>var_dump()</strong>&#8221; function.</li>
</ul>
</li>
<li><strong>inArray(array, string):</strong>
<ul>
<li>Function to find if the string is in the array. Clone of PHP\&#8217;s &#8220;<strong>in_array()</strong>&#8221; function.</li>
</ul>
</li>
<li><strong>inArrayI(</strong><strong>array, string):</strong>
<ul>
<li>Function to find if the string is in the array. Clone of PHP\&#8217;s &#8220;<strong>in_array()</strong>&#8221; function. (its case insensitive)</li>
</ul>
</li>
<li><strong>getMouseX(event):</strong>
<ul>
<li>Function to find the current X position of the mouse/cursor.</li>
</ul>
</li>
<li><strong>getMouseY(event):</strong>
<ul>
<li>Function to find the current Y position of the mouse/cursor.</li>
</ul>
</li>
<li><strong>getMouseXY(event):</strong>
<ul>
<li>Function to find the current X and Y positions of the mouse/cursor as an array.</li>
</ul>
</li>
<li><strong>getBrowserName():</strong>
<ul>
<li>Function to return the name of the web browser.</li>
</ul>
</li>
<li><strong>isBrowserIe():</strong>
<ul>
<li>Function to return &#8220;<strong>true</strong>&#8221; if the browser is &#8220;<strong>Microsoft Internet Explorer</strong>&#8221; else return &#8220;<strong>false</strong>&#8220;.</li>
</ul>
</li>
<li><strong>isBrowserOpera():</strong>
<ul>
<li>Function to return &#8220;<strong>true</strong>&#8221; if the browser is &#8220;<strong>Opera</strong>&#8221; else return &#8220;<strong>false</strong>&#8220;.</li>
</ul>
</li>
<li><strong>isBrowserNetscape():</strong>
<ul>
<li>Function to return &#8220;<strong>true</strong>&#8221; if the browser is &#8220;<strong>Firefox</strong>&#8221; or &#8220;<strong>Netscape</strong>&#8221; else return &#8220;<strong>false</strong>&#8220;.</li>
</ul>
</li>
<li><strong>getTotalImages():</strong>
<ul>
<li>Function to return the number of images used in the current page.</li>
</ul>
</li>
<li><strong>explode(delimiter,</strong> <strong>string):</strong>
<ul>
<li>Function to Split a string by a specified delimiter. A Clone of PHP\&#8217;s &#8220;<strong>explode</strong>&#8221; function.</li>
</ul>
</li>
<li><strong>end(</strong><strong>string / array):</strong>
<ul>
<li>Function to return the last character of a string or the last element of the array. A Clone of PHP\&#8217;s &#8220;<strong>end</strong>&#8221; function.</li>
</ul>
</li>
</ol>
</li>
</ul>
<p><script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> Change log (1.1)</p>
<ol>
<li><strong>isBrowserFirefox()</strong>:
<ul>
<li>Function to return &#8220;<strong>true</strong>&#8221; if the browser is &#8220;<strong>Firefox</strong>&#8221; else return &#8220;<strong>false</strong>&#8220;.</li>
</ul>
</li>
<li><strong>isBrowserSafari()</strong>:
<ul>
<li>Function to return &#8220;<strong>true</strong>&#8221; if the browser is &#8220;<strong>Safari</strong>&#8221; else return &#8220;<strong>false</strong>&#8220;.</li>
</ul>
</li>
<li><strong>isBrowserChrome()</strong>:
<ul>
<li>Function to return &#8220;<strong>true</strong>&#8221; if the browser is &#8220;<strong>Chrome</strong>&#8221; else return &#8220;<strong>false</strong>&#8220;.</li>
</ul>
</li>
<li><strong>$$(idName)</strong>:
<ul>
<li>Function to similar to <strong>&#8220;document.getElementById(&#8216;idName&#8217;)&#8221;</strong>.</li>
</ul>
</li>
</ol>
<p><em><strong>To </strong><strong>download the latest code, <a title="rochak.js" href="http://rochakchauhan.com/rochak1.1.js" target="_blank">right click here</a> and click on &#8220;Save link as&#8221; or &#8220;Save target as&#8221;.</strong></em></p>
<ul>
<li><a title="rochak-1.0.js" href="http://rochakchauhan.com/rochak1.0.js" target="_blank">rochak-1.0.js</a></li>
<li><a title="rochak1.1.js" href="http://rochakchauhan.com/rochak1.1.js" target="_blank">rochak-1.1.js</a></li>
</ul>
<p>Or visit:   <a href="http://www.jsclasses.org/package/6-JavaScript-Manipulate-text-arrays-and-get-browser-details.html" target="_blank">http://www.phpclasse.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/10/10/rochakjs-javascript-class-of-common-functions/feed/</wfw:commentRss>
		<slash:comments>397</slash:comments>
		</item>
		<item>
		<title>PHP vs JSP</title>
		<link>http://rochakchauhan.com/blog/2008/09/25/php-vs-jsp/</link>
		<comments>http://rochakchauhan.com/blog/2008/09/25/php-vs-jsp/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 14:17:48 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[JSP]]></category>
		<category><![CDATA[PHP vs JSP]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/?p=428</guid>
		<description><![CDATA[In my opinion, developing a Web based application in JSP (Java) is more or less like killing a housefly with a bazooka. Of course you will hit your target, no one is denying that, but you will also have collateral damage along with it. This damage ranges from Cost of hardware, hosting, servers and development. &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/09/25/php-vs-jsp/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">In my opinion, developing a Web based application in JSP (Java) is more or less like killing a housefly with a bazooka. Of course you will hit your target, no one is denying that, but you will also have collateral damage along with it. This damage ranges from Cost of hardware, hosting, servers and development. Not to mention the time taken to develop, edit or modify the application.</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">But, that’s just me, I’ll let you to decide and let me know after going through these factors. </span></p>
<table class="MsoNormalTable" style="border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="55" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 10pt; font-family: Tahoma;">SNO</span></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 10pt; font-family: Tahoma;">Function / Feature</span></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 10pt; font-family: Tahoma;">JSP</span></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 10pt; font-family: Tahoma;">PHP</span></strong></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">1.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Programming Approach</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Tahoma;"><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Completely Object Oriented</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;"><span> </span>Advantage:</span></strong><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Clean code</span></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;"><span> </span>Disadvantage: </span></strong></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Way too descriptive<strong></strong></span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Tahoma;"><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Mainly a Scripting Language</span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Tahoma;"><span>2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">It can also be used in OOPS from   PHP 5 and above.</span></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;"><span> </span>Advantage:</span></strong><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Functional and quick coding, you can use OOP practices at your   convenience</span></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;">Disadvantage:</span></strong><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">May get clumsy</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">2.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">String and data manipulation</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Rich library, too much   descriptive and object oriented code</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Rich functionality. Functional   and easy coding.</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Has inbuilt support to use third   party libraries from other programming languages like Java, C and Dot.net</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">3.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Web Oriented features</span></p>
<ol type="1">
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Includes </span></li>
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Mails </span></li>
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">File Uploads </span></li>
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Form Handling </span></li>
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Sessions </span></li>
</ol>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;">Advantage:</span></strong><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Almost everything is built in or supported by libraries. </span></p>
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;">Disadvantage:</span></strong></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Complicated and way too much of code.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><strong><span style="font-size: 10pt; font-family: Tahoma;">Advantages:</span></strong><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Inbuilt functionality and easy to use functions, written for the   specific tasks</span></p>
<p class="MsoNormal" style="margin-left: 18pt; text-indent: -18pt;"><!--[if !supportLists]--><span style="font-size: 10pt; font-family: Symbol;"><span>·<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span><!--[endif]--><span style="font-size: 10pt; font-family: Tahoma;">Reduces the lines of code and time taken to write an application.</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">4.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Database Access features</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Standard JDBC structure/ Use EJB/   Struts framework built over JDBC. Descriptive and too much overhead or boiler   plate code involved. Uses the same API for all databases using JDBC drivers</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Dedicated inbuilt libraries for   most of the commonly used databases. Very tight integration with Oracle, MySQL   and PostGRE SQL. Very minimal boiler plate code required. The libraries and   results are straight forward, robust and easy to use.</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">5. </span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">XML/XSL/XPATH</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Use standard SAX/DOM parsers. Too   much boiler plate code involved. Well defined APIs and stable implementations   are available for XSL and XPATH</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">SAX and DOM parsers available are   easy to use and to the point. Another library, Simple XML provides very easy   OO approach to handling XML data. XSL and XPATH functionality is also built   in.</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">6.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Extensibility</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Java Classes and Libraries. <span class="grame">Run’s</span> in sandbox and hard JNI approach needed to integrate   with server programs.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">PHP/C/Any thing executable by the   underlying OS platform. Can very easily interact with programs on the server.   Very good support for native code.</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">7.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Dynamic Graphics/PDF and bells   and whistles</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Almost everything has a readymade   library</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Supported internally or though   libraries.</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">8.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Web Services/SOAP</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Addon Libraries like Axis,   JAX-WS, etc.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">In Built</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">9. </span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Portals</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Spec <strong><span style="font-family: Tahoma;">JSR-168 and 286</span></strong></span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Many different Portal frameworks</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">10.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Learning curve</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">It helps if you have an decent   understanding of JAVA and its architecture. </span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">If you know C/C++, then you are   halfway through to learn PHP.</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">11.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Support</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">It has support and backing of   Industry giants like Sun and IBM.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">It enjoys the backing of Oracle,   Sun, IBM, Microsoft and Zend.</span></p>
</td>
</tr>
<tr>
<td style="padding: 0cm 5.4pt; width: 41.4pt;" width="55" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">12.</span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 108pt;" width="144" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Hardware cost and requirement. </span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 159.25pt;" width="212" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Well this is one factor which   makes PHP a favourite. The cost of procuring a server is exponentially higher   than that of getting PHP server up and running.<span> </span></span></p>
</td>
<td style="padding: 0cm 5.4pt; width: 117.45pt;" width="157" valign="top">
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">Cost of hosting a small and   medium scale PHP application start from as low as $9 per month.<span> </span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">For a decent enterprise level   application server with an enterprise PHP framework, the cost would come out   to be around $50 per month.</span></p>
</td>
</tr>
</tbody>
</table>
<h1 style="text-align: center;" align="center"><strong><em>Sample Codes for comparison</em></strong></h1>
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 12pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal" style="margin-left: 36pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></sub></strong><!--[endif]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">Hello World</span></sub></strong></p>
<table class="MsoNormalTable" style=" width: 441.9pt; margin-left: 11.4pt; border-collapse: collapse;" cellspacing="0" cellpadding="0" width="589">
<tbody>
<tr style="height: 13.75pt;">
<td width="279" height="29" valign="top" style="padding: 0cm 5.4pt; width: 209.15pt; height: 13.75pt;">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">JSP</span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 13.75pt;" width="310" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">PHP</span></sub></strong></p>
</td>
</tr>
<tr style="height: 103.3pt;">
<td style="padding: 0cm 5.4pt; width: 209.15pt; height: 103.3pt;" width="279" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;JSP &#8212;   Hello World!&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;%   out.println(&#8221; Hello World&#8221;); %&gt; !</span></sub></em></strong></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;/body&gt;<br />
&lt;/html&gt;</span></sub><strong><sub></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 103.3pt;" width="310" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;PHP &#8212;   Hello World!&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;?php echo   ”Hello World”; ?&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;/body&gt;<br />
&lt;/html&gt;</span></sub><strong><sub></sub></strong></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"> </span></sub></strong></p>
<p class="MsoNormal" style="margin-left: 36pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"><span>2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></sub></strong><!--[endif]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">Print Date as DD/MM/YYYY</span></sub></strong></p>
<table class="MsoNormalTable" style="border: medium none; width: 441.9pt; margin-left: 11.4pt; border-collapse: collapse;" cellspacing="0" cellpadding="0" width="589">
<tbody>
<tr style="height: 13.75pt;">
<td style="padding: 0cm 5.4pt; width: 240pt; height: 13.75pt;" width="320" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">JSP</span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 201.9pt; height: 13.75pt;" width="269" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">PHP</span></sub></strong></p>
</td>
</tr>
<tr style="height: 103.3pt;">
<td style="padding: 0cm 5.4pt; width: 240pt; height: 103.3pt;" width="320" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;JSP – Print   date&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;%</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">java.util.Calendar   cal =java.util.Calendar.getInstance();</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">out.println(</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">new   SimpleDateFormat(“dd/MM/yyyy).format(cal.getTime()?)</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">); </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">%&gt;</span></sub></em></strong><sub><span style="font-family: Tahoma;"><br />
&lt;/body&gt;<br />
&lt;/html&gt;</span></sub><strong><sub></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 201.9pt; height: 103.3pt;" width="269" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;PHP – Print   Date&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;?php echo   date(“d/m/Y”); ?&gt;<span> </span></span></sub></em></strong></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;/body&gt;<br />
&lt;/html&gt;</span></sub><strong><sub></sub></strong></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin-left: 18pt;"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"> </span></sub></strong></p>
<p class="MsoNormal" style="margin-left: 36pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"><span>3.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></sub></strong><!--[endif]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">Read / Write session variable </span></sub></strong></p>
<table class="MsoNormalTable" style="width: 441.9pt; margin-left: 11.4pt; border-collapse: collapse;" cellspacing="0" cellpadding="0" width="589">
<tbody>
<tr style="height: 13.75pt;">
<td style="padding: 0cm 5.4pt; width: 209.15pt; height: 13.75pt;" width="279" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">JSP</span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 13.75pt;" width="310" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">PHP</span></sub></strong></p>
</td>
</tr>
<tr style="height: 103.3pt;">
<td style="padding: 0cm 5.4pt; width: 209.15pt; height: 103.3pt;" width="279" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;JSP – Session   Read/Write&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;%</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">//Get current   session or create a new session</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">HtppSession   session = request.getSession(true); </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"> </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">//Add   information to the session</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">session.setAttribute(“name”,   “Pramati”);</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"> </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">//Print the   information</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">out.println(session.getAttribute(“name”);</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">%&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;/body&gt;<br />
&lt;/html&gt;</span></sub><strong><sub></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 103.3pt;" width="310" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;PHP – Session   Read/Write&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;?php</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">//Get current session   or create a new session</span></sub></em></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">session_start(); </span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"> </span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">//Add information   to the session</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">$_SESSION['name']=   “Pramati”;</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"> </span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">//Print the   information</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">echo   $_SESSION['name'];</span></sub></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">?&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;/body&gt;<br />
&lt;/html&gt;</span></sub><strong><sub></sub></strong></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"> </span></sub></strong></p>
<p class="MsoNormal" style="margin-left: 36pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"><span>4.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></sub></strong><!--[endif]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"> </span></sub></strong></p>
<p class="MsoNormal" style="margin-left: 72pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"><span>a.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></sub></strong><!--[endif]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">File Uploading &#8211; Form</span></sub></strong></p>
<table class="MsoNormalTable" style=" width: 441.9pt; margin-left: 11.4pt; border-collapse: collapse;" cellspacing="0" cellpadding="0" width="589">
<tbody>
<tr style="height: 13.75pt;">
<td style=" padding: 0cm 5.4pt; width: 209.15pt; height: 13.75pt;" width="279" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">JSP</span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 13.75pt;" width="310" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">PHP</span></sub></strong></p>
</td>
</tr>
<tr style="height: 103.3pt;">
<td style="padding: 0cm 5.4pt; width: 209.15pt; height: 103.3pt;" width="279" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;JSP – File   upload form&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;form<span> </span>action=&#8221;ProcessFileUpload.jsp&#8221; method=&#8221;post&#8221;   enctype=&#8221;multipart/form-data&#8221;&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span></span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">File   1:&lt;input type=&#8221;file&#8221; name=&#8221;file1&#8243;/&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;br/&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;input   type=&#8221;submit&#8221; name=&#8221;Submit&#8221; value=&#8221;Upload   File&#8221;/&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;/form&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;/body&gt;<br />
&lt;/html&gt;</span></sub>
</p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"> </span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">Please Note: No in-built support for file uploading   in JSP. You have to rely on external libraries. This example uses Apache&#8217;s   commons-upload lib.</span></sub></p>
<p class="MsoNormal"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"> </span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 103.3pt;" width="310" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;html&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;head&gt;<br />
<span> </span>&lt;title&gt;PHP – File   upload form&lt;/title&gt;</span></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"><span> </span>&lt;/head&gt;<br />
&lt;body&gt;</span></sub>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;form<span> </span>action=&#8221;ProcessFileUpload.php&#8221; method=&#8221;post&#8221;   enctype=&#8221;multipart/form-data&#8221;&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span></span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">File   1:&lt;input type=&#8221;file&#8221; name=&#8221;file1&#8243;/&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;br/&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;input   type=&#8221;submit&#8221; name=&#8221;Submit&#8221; value=&#8221;Upload   File&#8221;/&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;/form&gt;</span></sub></em></strong></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">&lt;/body&gt;<br />
&lt;/html&gt;</span></sub><strong><sub></sub></strong></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 18pt;"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">4.</span></sub></strong></p>
<p class="MsoNormal" style="margin-left: 72pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"><span>b.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></sub></strong><!--[endif]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">File Uploading – Backend Code</span></sub></strong></p>
<table class="MsoNormalTable" style="border: medium none; width: 441.9pt; margin-left: 11.4pt; border-collapse: collapse;" cellspacing="0" cellpadding="0" width="589">
<tbody>
<tr style="height: 13.75pt;">
<td style=" padding: 0cm 5.4pt; width: 210.15pt; height: 13.75pt;" width="280" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">JSP</span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 231.75pt; height: 13.75pt;" width="309" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">PHP</span></sub></strong></p>
</td>
</tr>
<tr style="height: 103.3pt;">
<td style="padding: 0cm 5.4pt; width: 210.15pt; height: 103.3pt;" width="280" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">Code for <strong><em>ProcessFileUpload.jsp</em></strong></span></sub></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;%</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">if(ServletFileUpload.isMultipartContent(request))</span></sub></em></strong><strong><sub><span style="font-family: Tahoma;">?</span></sub></strong><strong><em><sub></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">{</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">FileItemFactory   f = new DiskFileItemFactory();</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">ServletFileUpload   upload = new ServletFileUpload(f);</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">List items =   upload.parseRequest(request);</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">Iterator   itemsIter = items.getIterator();</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>if(iter.hasNext())</span></sub></em></strong><strong><sub><span style="font-family: Tahoma;">?</span></sub></strong><strong><em><sub></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>{</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>File uploadedFile = new   File(item.getName()); </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>item.write(uploadedFile); </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span><span> </span>}</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">}</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">%&gt;</span></sub></em></strong><sub></sub></p>
<p class="MsoNormal"><sub><span style="font-family: Tahoma;"> </span></sub></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">Please Note: No in-built support for file uploading   in JSP. You have to rely on external libraries. This example uses Apache&#8217;s   commons-upload lib.</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"> </span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 231.75pt; height: 103.3pt;" width="309" valign="top">
<p class="MsoNormal"><sub><span style="font-family: Tahoma;">Code for <strong><em>ProcessFileUpload.php</em></strong> </span></sub></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;?php </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">if   ($_FILES["file"]["error"] &gt; 0)</span></sub></em></strong><strong><sub><span style="font-family: Tahoma;">?</span></sub></strong><strong><em><sub><span style="font-family: Tahoma;"> </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">{</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>echo &#8220;Error: &#8221; .   $_FILES["file"]["error"];</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">}</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">else</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">{</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>move_uploaded_file( </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>$_FILES["file"]["tmp_name"], </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"><span> </span>&#8220;upload/&#8221; .   $_FILES["file"]["name"]);</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">}</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">?&gt;</span></sub></em></strong><strong><sub></sub></strong></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 12pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal" style="text-align: center;" align="center"><strong><span style="font-size: 12pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal" style="margin-left: 36pt; text-indent: -18pt;"><!--[if !supportLists]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;"><span>5.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></sub></strong><!--[endif]--><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">Connect to the Database (MySql)</span></sub></strong></p>
<table class="MsoNormalTable" style="width: 441.9pt; margin-left: 11.4pt;" cellspacing="0" cellpadding="0" width="589">
<tbody>
<tr style="height: 13.75pt;">
<td style="padding: 0cm 5.4pt; width: 209.15pt; height: 13.75pt;" width="279" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">JSP</span></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 13.75pt;" width="310" valign="top">
<p class="MsoNormal" style="text-align: center;" align="center"><strong><sub><span style="font-size: 12pt; font-family: Tahoma;">PHP</span></sub></strong></p>
</td>
</tr>
<tr style="height: 103.3pt;">
<td style="padding: 0cm 5.4pt; width: 209.15pt; height: 103.3pt;" width="279" valign="top">
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">&lt;%@ page import=&#8221;java.sql.*&#8221; %&gt;</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">&lt;% </span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">Connetion conn = null;</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">java.sql.Connection conn= null;</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">Statement st = null;</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">ResultSet rs = null;</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"> </span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">try {</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"><span> </span>Class.forName(&#8220;com.mysql.jdbc.Driver&#8221;).newInstance();</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"><span> </span>Class.forName(&#8220;org.gjt.mm.mysql.Driver&#8221;).newInstance();</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"><span> </span>conn   = DriverManager.getConnection(<span> </span>&#8220;jdbc:mysql://localhost/jsp?user=xxx&amp;password=xxx&#8221;);</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"><span> </span>st   = conn.createStatement();</span></sub></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;"><span> </span>//   connection made&#8230;.<br />
}</span></sub></strong><strong><sub></sub></strong></p>
</td>
<td style="padding: 0cm 5.4pt; width: 232.75pt; height: 103.3pt;" width="310" valign="top">
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">&lt;?php</span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">$dbserver=”locations”; </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">$username=&#8221;username&#8221;;<br />
$password=&#8221;password&#8221;;<br />
$database=&#8221;your_database&#8221;;</span></sub></em></strong></p>
<p><strong><em><sub>mysql_connect($dbserver,$username,$password);<br />
@mysql_select_db($database) or die( &#8220;Unable to select database&#8221;);</sub></em></strong>
</p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;"> </span></sub></em></strong></p>
<p class="MsoNormal"><strong><em><sub><span style="font-family: Tahoma;">//connection </span></sub></em></strong><strong><em><sub><span style="font-family: Tahoma;">made…</span></sub></em></strong></p>
<p class="MsoNormal"><strong><sub><span style="font-family: Tahoma;">?&gt;</span></sub></strong><strong><sub></sub></strong></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/09/25/php-vs-jsp/feed/</wfw:commentRss>
		<slash:comments>510</slash:comments>
		</item>
		<item>
		<title>Most common JavaScript mistakes and their solutions</title>
		<link>http://rochakchauhan.com/blog/2008/09/25/most-common-javascript-mistakes/</link>
		<comments>http://rochakchauhan.com/blog/2008/09/25/most-common-javascript-mistakes/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 10:39:27 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JavaScript mistakes]]></category>
		<category><![CDATA[rochak.js]]></category>
		<category><![CDATA[solutions]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/?p=410</guid>
		<description><![CDATA[JavaScript has come a long way from being used just as Client Side Form Validator to becoming the backbone of Web 2.0 rich web applications. In the current scenario, every web developer have to learn JavaScript as there is hardly any Web 2.0 application which does not implement JavaScript. In my opinion followings are the &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/09/25/most-common-javascript-mistakes/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>JavaScript has come a long way from being used just as <em>Client Side Form Validator</em> to becoming the backbone of Web 2.0 rich web applications. In the current scenario, every web developer have to learn JavaScript as there is hardly any Web 2.0 application which does not implement JavaScript.</p>
<p>In my opinion followings are the most common errors/mistakes made during JavaScript implementation.</p>
<ol>
<li><strong><em>Calling JavaScript Code without any event:</em></strong>This is the first error any JavaScript developer is bound to make. Allow me to illustrate it with a real life example. Suppose, we need to alert the content inside a div with id &#8220;content&#8221;. The novice developer would write:
<pre lang="javascript">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Invalid JavaScript Code&lt;/title&gt;
    &lt;script type="text/javascript" language="javascript"&gt;
        var content=document.getElementById('content').innerHTML;
        alert(content);
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="content"&gt;This is the sample content&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Needless to say, the above code will throw an error. The technical explanation of the error is as follows. As JavaScript is an interpreted scripting language, it would try to read the content on the line 6. However, at that moment, the HTML had not been rendered and hence JavaScript will find no div. Its solution is very simple and elementary. All you have to do is to call this code on some event, like onload , onclick etc.  Following is the correct way to do it:</p>
<pre lang="javascript">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Valid JavaScript Code&lt;/title&gt;
    &lt;script type="text/javascript" language="javascript"&gt;
        function init(){
            var content=document.getElementById('content').innerHTML;
            alert(content);
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body onload="init()"&gt;
&lt;div id="content"&gt;This is the sample content&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</li>
<li><strong><em>Reading string as array:</em></strong>Well, once I committed this mistake and spent over 2 days to find this issue from 102 lines of JavaScript. Suppose you need to read and display the 3rd  character of a string. any C or PHP developer is bound to write the code like this:
<pre lang="javascript">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Invalid JavaScript Code&lt;/title&gt;
    &lt;script type="text/javascript" language="javascript"&gt;
        function readString(){
            var str="JavaScript";
            alert(str[2]);
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type="button" onclick="readString();" /&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Quite interestingly, the above code if alert &#8220;v&#8221; in Firefox or Mozilla. On few Internet Explorers it will throw an error. The reason is that reading string as an array (str[2]) is not an cross browser compatible. The correct way code is as follows:</p>
<pre lang="javascript">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Valid JavaScript Code&lt;/title&gt;
    &lt;script type="text/javascript" language="javascript"&gt;
        function readString(){
            var str="JavaScript";
            alert(str.charAt(2));
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type="button" onclick="readString();" /&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</li>
<li><strong><em>Validating for an blank field in JavaScript:</em></strong>This is one of the most common bug your quality analyst or client would let you know. When you are validating a blank field (say username). Most of the JavaScript developers  would write the following code to validate it:
<pre lang="javascript">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Valid JavaScript Code&lt;/title&gt;
    &lt;script type="text/javascript" language="javascript"&gt;
        function validate(){
            var value=document.getElementById('uname').value;
            if(value.length&lt;1) {
                 alert("ERROR: Username cannot be left blank");
                 return false;
             }
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body onload="init()"&gt;
Username: &lt;input type="text" id="uname"&gt;
&lt;input type="button" onclick="validate()" /&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
</li>
</ol>
<p>Although the above code may seems to work, but it fails as soon as you enter any invisible character like space, newline/enter or a tab. The check is that the length of the string entered should not be less than 1 (in this case). What the developer has failed to negotiate that three invisible characters like spaces would count 3 but would be invalid. The solution is simple. Trim (similar to one in PHP) the value before applying this check. Unfortunately, there is no inbuilt function to trim a string. However you can use it from my free library <a title="Click to view source of rochak.js" href="http://rochakchauhan.com/rochak.js" target="_blank">rochak.js</a> as used in the following example.</p>
<pre lang="javascript">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Valid JavaScript Code&lt;/title&gt;
    &lt;script type="text/javascript" language="javascript" src="http://rochakchauhan.com/rochak.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" language="javascript"&gt;
        function validate(){
            var value=document.getElementById('uname').value;
            value=rochak.trim(value);
            if(value.length&lt;1) {
                 alert("ERROR: Username cannot be left blank");
                 return false;
             }
        }
    &lt;/script&gt;
&lt;/head&gt;
&lt;body onload="init()"&gt;
Username: &lt;input type="text" id="uname"&gt;
&lt;input type="button" onclick="validate()" /&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/09/25/most-common-javascript-mistakes/feed/</wfw:commentRss>
		<slash:comments>432</slash:comments>
		</item>
		<item>
		<title>Zend To Collaborate With Adobe</title>
		<link>http://rochakchauhan.com/blog/2008/09/20/zend-to-collaborate-with-adobe/</link>
		<comments>http://rochakchauhan.com/blog/2008/09/20/zend-to-collaborate-with-adobe/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 14:26:46 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech News]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Collaborate]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/?p=402</guid>
		<description><![CDATA[Original Source Zend.com Zend To Collaborate With Adobe To Accelerate Rich Web Application Development Using PHP and Open Source Flex Framework New Collaboration Combines the Flexibility, Reliability and Productivity of PHP Technology with the Powerful User Experience of Adobe Flex and Flash Technology Zend/PHP Conference and Expo, SANTA CLARA, Calif. — September 16, 2008 — &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/09/20/zend-to-collaborate-with-adobe/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Original Source <a title="Zend to collaborate with adobe" href="http://www.zend.com/en/company/news/press/zend-to-collaborate-with-adobe" target="_blank">Zend.com</a></p>
<p><span style="font-weight: bold;">Zend To Collaborate With Adobe To Accelerate Rich Web Application Development Using PHP and Open Source Flex Framework</span><br style="font-weight: bold;" /><br />
<span style="font-style: italic;">New Collaboration Combines the Flexibility, Reliability and Productivity of PHP Technology with the Powerful User Experience of Adobe Flex and Flash Technology</span><br style="font-style: italic;" /><br />
<span style="font-weight: bold;">Zend/PHP Conference and Expo, SANTA CLARA, Calif.</span> — <span style="font-weight: bold;">September 16, 2008</span> — Zend Technologies today announced a collaboration with Adobe Systems Incorporated to bring together the flexibility, productivity and enterprise reliability of Zend’s PHP technologies with the user experience benefits of Adobe Flex. The two companies will deliver technologies, content and services to make it easy for enterprise developers to build rich Internet applications (RIAs) using Flex on the client and PHP on the server. These RIAs are easier to use, speed real-time decision-making and increase employee productivity.</p>
<p>A key deliverable of this collaboration is the integration of Action Message Format (AMF) support into Zend Framework. AMF is an open, binary, high-speed format enabling Adobe® Flash® Player and Flex-based client applications to easily and rapidly exchange rich media and other data with servers. Flex is a highly productive, free open source framework for building and maintaining expressive web applications that deploy consistently across all major browsers and operating systems using Adobe® Flash® Player and to the desktop via Adobe® AIR™. Zend Framework is an open source PHP application framework best known for its support for flexible, efficient creation of web applications. AMF support in Zend Framework delivers optimized communication between server-side Zend Framework components and client-side Adobe Flex components. Now PHP developers will be able to leverage the fast, reliable transfer of data between the server and client tiers of their web applications. More information about AMF support is available at http://framework.zend.com and http://developer.adobe.com/flex/</p>
<p>In addition, Zend and Adobe plan to optimize the experience for developers using their respective development environments. Zend Studio and Adobe® Flex® Builder™, both built on the open source Eclipse platform, provide robust coding, debugging, and testing tools for professional developers. Today, the two environments enable greater productivity, simplified deployment and end-to-end debugging of applications. Moving forward, Zend and Adobe plan to identify and implement cross-product integration points that optimize developer workflow and reduce development time.</p>
<p>“Since bringing Flex to market, we’ve seen strong uptake among PHP developers, and we’re pleased to be collaborating with Zend and the PHP community to deliver deeper integration and increased productivity,” said David Wadhwani, General Manager, Platform Business Unit at Adobe. “The collaboration with Zend furthers Adobe’s commitment to open technology initiatives. Together, we will enable developers using Flex and Zend Framework to rapidly deliver highly engaging applications to both the browser and the desktop.”</p>
<p>“Zend’s mission is to enable companies investing in PHP technology to deliver world-class experiences using internet-standard technologies,” said Andi Gutmans, chief technical officer and co-founder of Zend. “By working more closely with Adobe, we believe our customers will be more equipped to deliver the performance, reliability, and engaging user experience that will differentiate their products and services.”</p>
<p><span style="font-weight: bold;">Customers Improve Enterprise Applications With Open Source Flex, Zend Framework, and PHP </span></p>
<p>Automotive Computer Services, Inc. (ACS) provides solutions that manage data needs for automotive dealerships throughout the United States:</p>
<p>&#8220;By moving our dealer management system from a desktop application to a web based service, we are able to drastically cut the costs of real-time data integration, while expanding our feature set and ability to integrate third party providers,&#8221; said John Coggeshall, chief technical officer at ACS. &#8220;With this radical change to a more centralized web application for our customers, desktop-like user experience and responsiveness is a key factor for success. The AMF and Flex integration into Zend Framework enables us to more cost-effectively meet these requirements by dramatically reducing latency of service requests, giving our customers the highly responsive application they demand and the rich user experience we expect.&#8221;</p>
<p>Stream Energy delivers multiple energy commodities like electricity and natural gas to over 300,000 customers throughout Texas and Georgia and they are rapidly expanding into other states:</p>
<p>“Our need to engage and provide relevant real-time information to our customers continually accelerates in the fast-moving deregulated consumer energy markets. Our web-based customer portal provides customer account information on our services and drives revenue collections that now number over $1.2 Billion dollars over the four year life of these systems,” said Jason Forgey, Senior Director of Information Technology at Dallas-based Stream Energy. “We built our new system with PHP middleware and an API gateway using web services with an Adobe Flex/Flash front-end and an Oracle database back-end, all using Zend Solutions.  The time-to-market and performance of PHP is one reason we have chosen to build with a Zend Solution that includes Zend Platform application server to manage our applications and queue up asynchronous jobs when under load, Zend Core managed PHP environment, Zend Studio in conjunction with Adobe Flex Builder for our development environment, and a Zend Framework and Adobe Flex based application portal.”</p>
<p>Adobe and Zend will undertake multiple initiatives to deliver product interoperability and integration, and define best practices for customers. The two companies have created dedicated areas within their respective developer portals where they will deliver a series of articles, white papers, and online seminars educating developers on best practices for delivering enterprise-ready solutions using PHP, Zend Framework, and Zend Platform, together with Adobe Flex, Adobe Flash Player, and Adobe AIR. Future product integration plans and technical documentation will be made available there. For more information, please visit Zend Developer Zone at http://devzone.zend.com/tag/Flex and Adobe Developer Connection at http://www.adobe.com/devnet/flex/</p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/09/20/zend-to-collaborate-with-adobe/feed/</wfw:commentRss>
		<slash:comments>296</slash:comments>
		</item>
		<item>
		<title>How to implement Tag Clouds in PHP</title>
		<link>http://rochakchauhan.com/blog/2008/09/15/how-to-implement-tag-clouds-in-php/</link>
		<comments>http://rochakchauhan.com/blog/2008/09/15/how-to-implement-tag-clouds-in-php/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 12:22:12 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Implement Tag Clouds]]></category>
		<category><![CDATA[Tag]]></category>
		<category><![CDATA[Tag Cloud]]></category>
		<category><![CDATA[Tag Clouds]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/?p=341</guid>
		<description><![CDATA[What are Tag Clouds? In technical terms “Tag cloud” can be defined as visual depiction of user-generated tags (words), used typically to describe the content of that page or the website. Not so long ago, we used “meta” tags to describe and define the html page and its contents. In the current time, tag clouds &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/09/15/how-to-implement-tag-clouds-in-php/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><strong><em><span style="font-family: Tahoma;">What are Tag Clouds?</span></em></strong></p>
<p class="MsoNormal"><strong><em><span style="font-size: 10pt; font-family: Tahoma;"> </span></em></strong></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">In technical terms “Tag cloud” can be defined as visual depiction of user-generated tags (words), used typically to describe the content of that page or the website. Not so long ago, we used “meta” tags to describe and define the html page and its contents. In the current time, tag clouds have replaced “meta” tags more than one reason.</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><strong><em><span style="font-family: Tahoma;">Why use Tag Clouds?</span></em></strong></p>
<p class="MsoNormal"><strong><em><span style="font-size: 10pt; font-family: Tahoma;"> </span></em></strong></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">The number one reason is SEO (Search engine optimization). Modern day search engines like Google do not bank only on the “Meta” tags to index a web page. They index pages based on its content as well as the links on that page. Apart from SEO, it helps providing a better user experience and each tag (word) is a link to that actual content. <span> </span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><strong><em><span style="font-family: Tahoma;">How to generate Tag Clouds?</span></em></strong></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: Tahoma;">The idea is to automate the process of Tag Cloud generation as soon as user writes a post or content on a page. It can be divided into two steps:</span></p>
<p class="MsoNormal" style="margin-left: 18pt;"><strong><em><span style="font-size: 10pt; font-family: Tahoma;"> </span></em></strong></p>
<ol style="margin-top: 0cm;" type="1">
<li class="MsoNormal"><strong><em><span style="font-size: 10pt; font-family: Tahoma;">Generate Tag Clouds from the      content.</span></em></strong></li>
</ol>
<p class="MsoNormal" style="margin-left: 72pt;"><span style="font-size: 10pt; font-family: Tahoma;">Ideally, we would like PHP code to extract relevant tags (keywords) from the content. We do not want common words like “is”, “this”, “the” to be keywords. We can set up our own set of rules depending on the requirement.</span></p>
<p class="MsoNormal" style="margin-left: 72pt;"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 72pt;"><span style="font-size: 10pt; font-family: Tahoma;">Sample PHP code:</span></p>
<pre>function generateTagCloud($content){
    $minTagLength=5;
    $maxTagLength=14;
    $baseFont=16;
    $returnArray=array(); 

    $content=str_replace("\r\n"," ",$content);
    $content=strip_tags($content);
    $tagArray=explode(" ",$content);
    for($i=0;$i=$minTagLength &amp;&amp; $len&lt; =$maxTagLength) {
            $returnArray[]=$tag;
        }
    }
    $returnArray=array_count_values($returnArray);
    arsort($returnArray);
    ksort($returnArray);
    return $returnArray;
}</pre>
<ol style="margin-top: 0cm;" type="1">
<li class="MsoNormal"><strong><em><span style="font-size: 10pt; font-family: Tahoma;">Display Tags according to their occurrence. </span></em></strong></li>
</ol>
<p class="MsoNormal" style="margin-left: 72pt;"><span style="font-size: 10pt; font-family: Tahoma;">After we have all the tags (keywords) we need to display then according their occurrence or presence in the content. In other words, the tag which is present more times in the content will be displayed in bigger fonts as the rest.</span></p>
<p class="MsoNormal" style="margin-left: 72pt;"><span style="font-size: 10pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 72pt;"><span style="font-size: 10pt; font-family: Tahoma;">Sample PHP code to achieve this is as follows: </span></p>
<pre>function displayTagCloud($tagCloudArray){
    $buffer="";
    foreach($tagCloudArray as $tags=&gt;$key) {
        $font=($baseFont+($key*10));
        $font=$font."px";
        $buffer.=" <span style="font-size: $font;
  float:left;"> $tags </span> ";
}$buffer.="";
        return $buffer;
 }</pre>
<p class="MsoNormal"><code><span style="font-size: 10pt; color: #007700;">Screenshot of final output:</span></code></p>
<p class="MsoNormal"><code><span style="font-size: 10pt; color: #007700;"> </span></code></p>
<p class="MsoNormal"><code><span style="font-size: 10pt; color: #007700;"><!--[if gte vml 1]><v :shapetype  id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"  path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v :stroke joinstyle="miter" /> </v><v :formulas> <v :f eqn="if lineDrawn pixelLineWidth 0" /> <v :f eqn="sum @0 1 0" /> <v :f eqn="sum 0 0 @1" /> <v :f eqn="prod @2 1 2" /> <v :f eqn="prod @3 21600 pixelWidth" /> <v :f eqn="prod @3 21600 pixelHeight" /> <v :f eqn="sum @0 0 1" /> <v :f eqn="prod @6 1 2" /> <v :f eqn="prod @7 21600 pixelWidth" /> <v :f eqn="sum @8 21600 0" /> <v :f eqn="prod @7 21600 pixelHeight" /> <v :f eqn="sum @10 21600 0" /> </v> <v :path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /> <o :lock v:ext="edit" aspectratio="t" /> <v :shape id="_x0000_i1025" type="#_x0000_t75" style='width:414.75pt;  height:219.75pt'> <v :imagedata src="file:///C:\Users\Rochak\AppData\Local\Temp\msohtml1\03\clip_image001.jpg" mce_src="file:///C:\Users\Rochak\AppData\Local\Temp\msohtml1\03\clip_image001.jpg"   o:title="Sample" /> </v>< ![endif]--><!--[if !vml]--><!--[endif]--></span></code></p>
<p class="MsoNormal"><strong><em><span style="font-size: 10pt; font-family: Tahoma;"> </span></em></strong><a href="http://rochakchauhan.com/blog/wp-content/uploads/2008/09/tagclouds.jpg"><img class="aligncenter size-full wp-image-342" title="Tagclouds" src="http://rochakchauhan.com/blog/wp-content/uploads/2008/09/tagclouds.jpg" alt="" width="500" height="264" /></a></p>
<p class="MsoNormal"><strong><em><span style="font-size: 10pt; font-family: Tahoma;"> </span></em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/09/15/how-to-implement-tag-clouds-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sun’s Web Stack Offers Choice of Operating Systems</title>
		<link>http://rochakchauhan.com/blog/2008/07/24/sun%e2%80%99s-web-stack-offers-choice-of-operating-systems/</link>
		<comments>http://rochakchauhan.com/blog/2008/07/24/sun%e2%80%99s-web-stack-offers-choice-of-operating-systems/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 04:09:40 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[sun]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2008/07/24/sun%e2%80%99s-web-stack-offers-choice-of-operating-systems/</guid>
		<description><![CDATA[Sun showed off its Web Stack on Tuesday, as its name indicates, the stack includes technology used to run Web sites and Web applications. It is based on the AMP portion of the LAMP stack (Linux, Apache, MySQL, Perl/Python/PHP), but users will have a choice of operating systems: Sun’s Solaris, Linux, Windows or other operating &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/07/24/sun%e2%80%99s-web-stack-offers-choice-of-operating-systems/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.infoworld.com/article/08/07/22/Sun-readies-Web-stack-featuring-choice-of-OSes_1.html">Sun showed off its Web Stack on Tuesday</a>, as its name indicates, the stack includes technology used to run Web sites and Web applications. It is based on the AMP portion of the LAMP stack (Linux, Apache, MySQL, Perl/Python/PHP), but users will have a choice of operating systems: Sun’s Solaris, Linux, Windows or other operating systems. The story says Sun will provide support for Solaris starting this quarter, for Linux starting next quarter, and for Windows and others starting later in the year.Let’s be honest — we knew this was coming as soon as Sun acquired MySQL, right? Except at that point, I thought it would be strictly a MAPS stack (MySQL, Apache, Perl/Python/PHP, Solaris). Maybe the Linux Foundation’s reaction to that idea wasn’t the only one that was adverse.</p>
<p>Whatever the motivation to offer multiple operating systems, it looks like Sun is focusing on working with rather than excluding other platforms, just like Canonical’s Mark Shuttleworth encouraged Linux developers to do when working on Linux desktop.</p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/07/24/sun%e2%80%99s-web-stack-offers-choice-of-operating-systems/feed/</wfw:commentRss>
		<slash:comments>261</slash:comments>
		</item>
		<item>
		<title>Top Ten Security Vulnerabilities in PHP Code !</title>
		<link>http://rochakchauhan.com/blog/2008/07/13/top-ten-security-vulnerabilities-in-php-code/</link>
		<comments>http://rochakchauhan.com/blog/2008/07/13/top-ten-security-vulnerabilities-in-php-code/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 08:29:57 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Security Vulnerabilities]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2008/07/13/top-ten-security-vulnerabilities-in-php-code/</guid>
		<description><![CDATA[1. Unvalidated Parameters Most importantly, turn off register_globals. This configuration setting defaults to off in PHP 4.2.0 and later. Access values from URLs, forms, and cookies through the superglobal arrays $_GET, $_POST, and $_COOKIE. Before you use values from the superglobal arrays, validate them to make sure they don&#8217;t contain unexpected input. If you know &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/07/13/top-ten-security-vulnerabilities-in-php-code/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<h2><span class="byline"></span> 1. Unvalidated Parameters</h2>
<p>Most importantly, turn off <code>register_globals</code>. This configuration setting defaults to off in PHP 4.2.0 and later. Access values from URLs, forms, and cookies through the superglobal arrays <code>$_GET</code>, <code>$_POST</code>, and <code>$_COOKIE</code>.</p>
<p>Before you use values from the superglobal arrays, validate them to make sure they don&#8217;t contain unexpected input. If you know what type of value you are expecting, make sure what you&#8217;ve got conforms to an expected format. For example, if you&#8217;re expecting a US ZIP Code, make sure your value is either five digits or five digits, a hyphen, and four more digits (ZIP+4). Often, regular expressions are the easiest way to validate data:</p>
<pre>if (preg_match('/^\d{5}(-\d{4})?$/',$_GET['zip'])) {
    $zip = $_GET['zip'];
} else {
    die('Invalid ZIP Code format.');
}</pre>
<p>If you&#8217;re expecting to receive data in a cookie or a hidden form field that you&#8217;ve previously sent to a client, make sure it hasn&#8217;t been tampered with by sending a hash of the data and a secret word along with the data. Put the hash in a hidden form field (or in the cookie) along with the data. When you receive the data and the hash, re-hash the data and make sure the new hash matches the old one:</p>
<pre>// sending the cookie
$secret_word = 'gargamel';
$id = 123745323;
$hash = md5($secret_word.$id);
setcookie('id',$id.'-'.$hash);

// receiving and verifying the cookie
list($cookie_id,$cookie_hash) = explode('-',$_COOKIE['id']);
if (md5($secret_word.$cookie_id) == $cookie_hash) {
    $id = $cookie_id;
} else {
    die('Invalid cookie.');
}</pre>
<p>If a user has changed the ID value in the cookie, the hashes won&#8217;t match. The success of this method obviously depends on keeping <code>$secret_word</code> secret, so put it in a file that can&#8217;t be read by just anybody and change it periodically. (But remember, when you change it, old hashes that might be lying around in cookies will no longer be valid.)</p>
<p><strong>See Also:</strong></p>
<ul>
<li> PHP Manual: Using Register Globals</li>
<li>PHP Cookbook: Recipe 9.7 (&#8220;Securing PHP&#8217;s Form Processing&#8221;), Recipe 14.3 (&#8220;Verifying Data with Hashes&#8221;)</li>
</ul>
<h2>2. Broken Access Control</h2>
<p>Instead of rolling your own access control solution, use PEAR modules. <code>Auth</code> does cookie-based authentication for you and <code>Auth_HTTP</code> does browser-based authentication.</p>
<p><strong>See Also:</strong></p>
<ul>
<li>PEAR Packages: <a href="http://pear.php.net/package-info.php?package=Auth">Auth</a>, <a href="http://pear.php.net/package-info.php?package=Auth_HTTP">Auth_HTTP</a>.</li>
</ul>
<h2>3. Broken Account and Session Management</h2>
<p>Use PHP&#8217;s built-in session management functions for secure, standardized session management. However, be careful how your server is configured to store session information. For example, if session contents are stored as world-readable files in /tmp, then any user that logs into the server can see the contents of all the sessions. Store the sessions in a database or in a part of the file system that only trusted users can access.</p>
<p>To prevent network sniffers from scooping up session IDs, session-specific traffic should be sent over SSL. You don&#8217;t need to do anything special to PHP when you&#8217;re using an SSL connection, but you do need to specially configure your webserver.</p>
<p><strong>See Also:</strong></p>
<ul>
<li>PHP Manual: <a href="http://www.php.net/session">Session handling functions</a></li>
<li>PHP Cookbook: Recipe 8.5 (&#8220;Using Session Tracking&#8221;), Recipe 8.6 (&#8220;Storing Sessions in a Database&#8221;)</li>
</ul>
<h2>4. Cross-Site Scripting (XSS) Flaws</h2>
<p>Never display any information coming from outside your program without filtering it first. Filter variables before including them in hidden form fields, in query strings, or just plain page output.</p>
<p>PHP gives you plenty of tools to filter untrusted data:</p>
<ul>
<li><code>htmlspecialchars()</code> turns <code>&amp; &gt; " &lt;</code> into their HTML-entity equivalents and can also convert 	single quotes by passing <code>ENT_QUOTES</code> as a second argument.</li>
<li><code>strtr()</code> filters any characters you&#8217;d like. Pass <code>strtr()</code> an array of characters and their replacements. To change <code>(</code> and <code>)</code> into their entity equivalents, which is recommended to prevent XSS attacks, do:<br />
<code> $safer = strtr($untrusted, array('(' =&gt; '(', ')' =&gt; ')'));</code></li>
<li><code>strip_tags()</code> removes HTML and PHP tags from a string.</li>
<li><code>utf8_decode()</code> converts the ISO-8859-1 characters in a string encoded with the Unicode UTF-8 encoding to single-byte ASCII characters. Sometimes cross-site scripting attackers attempt to hide their attacks in Unicode encoding. You can use <code>utf8_decode()</code> to peel off that encoding.</li>
</ul>
<p><strong>See Also:</strong></p>
<ul>
<li>PHP Manual: <a href="http://www.php.net/htmlspecialchars">htmlspecialchars()</a>, <a href="http://www.php.net/strtr">strtr()</a>, <a href="http://www.php.net/strip-tags">strip_tags()</a>, <a href="http://www.php.net/utf8-decode">utf8_decode()</a></li>
<li>PHP Cookbook: Recipe 8.8 (&#8220;Building a GET Query String&#8221;), Recipe 9.8 (&#8220;Escaping Control Characters from User Data&#8221;)</li>
</ul>
<h2>5. Buffer Overflows</h2>
<p>You can&#8217;t allocate memory at runtime in PHP and their are no pointers like in C so your PHP code, however sloppy it may be, won&#8217;t have any buffer overflows. What you do have to watch out for, however, are buffer overflows in PHP itself (and its extensions.) Subscribe to the php-announce mailing list to keep abreast of patches and new releases.</p>
<p><strong>See Also:</strong></p>
<ul>
<li> PHP Mailing Lists: <a href="http://www.php.net/mailing-lists.php">http://www.php.net/mailing-lists.php</a></li>
</ul>
<h2>6. Command Injection Flaws</h2>
<p>Cross-site scripting flaws happen when you display unfiltered, unescaped malicious content to a user&#8217;s browser. Command injection flaws happen when you pass unfiltered, unescaped malicious commands to an external process or database. To prevent command injection flaws, in addition to validating input, always escape user input before passing it to an external process or database.</p>
<p>If you&#8217;re passing user input to a shell (via a command like <code>exec()</code>, <code>system()</code>, or the backtick operator), first, ask yourself if you really need to. Most file operations can be performed with native PHP functions. If you absolutely, positively need to run an external program whose name or arguments come from untrusted input, escape program names with <code>escapeshellcmd()</code> and arguments with <code>escapeshellarg()</code>.</p>
<p>Before executing an external program or opening an external file, you should also canonicalize its pathname with <code>realpath()</code>. This expands all symbolic links, translates <code>.</code> (current directory) <code>..</code> (parent directory), and removes duplicate directory separators. Once a pathname is canonicalized you can test it to make sure it meets certain criteria, like being beneath the web server document root or in a user&#8217;s home directory.</p>
<p>If you&#8217;re passing user input to a SQL query, escape the input with <code>addslashes()</code> before putting it into the query. If you&#8217;re using MySQL, escape strings with <code>mysql_real_escape_string()</code> (or <code>mysql_escape_string()</code> for PHP versions before 4.3.0). If you&#8217;re using the PEAR DB database abstraction layer, you can use the DB::quote() method or use a query placeholder like <code>?</code>, which automatically escapes the value that replaces the placeholder.</p>
<p><strong>See Also:</strong></p>
<ul>
<li> PHP Manual: <a href="http://www.php.net/escapeshellcmd">escapeshellcmd()</a>, <a href="http://www.php.net/escapeshellarg">escapeshellarg()</a>, <a href="http://www.php.net/realpath">realpath()</a>, <a href="http://www.php.net/addslashes">addslashes()</a>, <a href="http://www.php.net/mysql_real_escape_string">mysql_real_escape_string()</a>, <a href="http://www.php.net/mysql_escape_string">mysql_escape_string()</a></li>
<li> PEAR Package: <a href="http://pear.php.net/package-info.php?package=DB">DB</a>, DB Documentation</li>
<li> PHP Cookbook: Recipe 18.20 (&#8220;Escaping Shell Metacharacters&#8221;), Recipe 10.9 (&#8220;Escaping Quotes&#8221;)</li>
</ul>
<h2>7. Error Handling Problems</h2>
<p>If users (and attackers) can see the raw error messages returned from PHP, your database, or external programs, they can make educated guesses about how your system is organized and what software you use. These educated guesses make it easier for attackers to break into your system. Error messages shouldn&#8217;t contain any descriptive system information. Tell PHP to put error messages in your server&#8217;s error log instead of displaying them to a user with these configuration directives:</p>
<pre>log_errors = On
display_errors = Off</pre>
<p><strong>See Also:</strong></p>
<ul>
<li> PHP Manual: <a href="http://www.php.net/errorfunc">Error Handling and Logging Functions</a></li>
<li> PHP Cookbook: Recipe 8.14 (&#8220;Hiding Error Messages from Users&#8221;)</li>
</ul>
<h2>8. Insecure Use of Cryptography</h2>
<p>The <code>mcrypt</code> extension provides a standardized interface to many popular cryptographic algorithms. Use <code>mcrypt</code> instead of rolling your own encryption scheme. Also, be careful about where (if anywhere) you store encryption keys. The strongest algorithm in the world is pointless if an attacker can easily obtain a key for decryption. If you need to store keys at all, store them apart from encrypted data. Better yet, don&#8217;t store the keys and prompt users to enter them when something needs to be decrypted. (Of course, if you&#8217;re prompting a user over the web for sensitive information like an encryption key, that prompt and the user&#8217;s reply should be passed over SSL.)</p>
<p><strong>See Also:</strong></p>
<ul>
<li>PHP Manual: <a href="http://www.php.net/mcrypt">Mcrypt Encryption Functions</a></li>
<li>PHP Cookbook: Recipe 14.7 (&#8220;Encrypting and Decrypting Data&#8221;)</li>
</ul>
<h2>9. Remote Administration Flaws</h2>
<p>When possible, run remote administration tools over an SSL connection to prevent sniffing of passwords and content. If you&#8217;ve installed third-party software that has a remote administration component, change the default administrative user names and passwords. Change the default administrative URL as well, if possible. Running administrative tools on a different web server than the public web server that the administrative tool administrates can be a good idea as well.</p>
<h2>10. Web and Application Server Misconfiguration</h2>
<p>Keep on top of PHP patches and security problems by subscribing to the php-announce mailing list. Stay away from the automatic PHP source display handler (<code>AddType application/x-httpd-php-source .phps</code>), since it lets attackers look at your code. Of the two sample <code>php.ini</code> files distributed with PHP ( <code>php.ini-dist</code> and <code>php.ini-recommended</code>), use <code>php.ini-recommended</code> as a base for your site configuration.</p>
<p><em><strong>Read the Original Post at:</strong></em> <a href="http://www.sklar.com/page/article/owasp-top-ten" title="Original Post" target="_blank">http://www.sklar.com/page/article/owasp-top-ten</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/07/13/top-ten-security-vulnerabilities-in-php-code/feed/</wfw:commentRss>
		<slash:comments>373</slash:comments>
		</item>
		<item>
		<title>Sun plans JavaFX for the desktop</title>
		<link>http://rochakchauhan.com/blog/2008/05/09/sun-plans-javafx-for-the-desktop/</link>
		<comments>http://rochakchauhan.com/blog/2008/05/09/sun-plans-javafx-for-the-desktop/#comments</comments>
		<pubDate>Fri, 09 May 2008 03:29:21 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tech News]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[sun]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2008/05/09/sun-plans-javafx-for-the-desktop/</guid>
		<description><![CDATA[Sun Microsystems (NSDQ: JAVA) has a long ways to go before it steps up to compete with Adobe Systems (NSDQ: ADBE) Flash or AJAX or even Microsoft (NSDQ: MSFT) Silverlight in building Web 2.0 applications. But it clearly has that goal in mind as it works on producing a version of JavaFX for the desktop, &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/05/09/sun-plans-javafx-for-the-desktop/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span id="articleBody">Sun Microsystems (NSDQ: <a href="http://www.techweb.com/financialCenter/index.jhtml?Account=techweb&amp;Page=QUOTE&amp;Ticker=JAVA" target="_blank" class="stockLink">JAVA</a>) has a long ways to go before it steps up to compete with Adobe Systems (NSDQ: <a href="http://www.techweb.com/financialCenter/index.jhtml?Account=techweb&amp;Page=QUOTE&amp;Ticker=ADBE" target="_blank" class="stockLink">ADBE</a>) Flash or AJAX or even Microsoft (NSDQ: <a href="http://www.techweb.com/financialCenter/index.jhtml?Account=techweb&amp;Page=QUOTE&amp;Ticker=MSFT" target="_blank" class="stockLink">MSFT</a>) Silverlight in building Web 2.0 applications. But it clearly has that goal in mind as it works on producing a version of JavaFX for the desktop, which it seeks to launch this fall.Sun&#8217;s Param Singh, senior director of Java marketing and veteran executive of Apple&#8217;s Multimedia Group, filled in some of the gaps in the information available on JavaFX in an interview Wednesday, the second day of Sun&#8217;s 13th annual user group, JavaOne, in San Francisco.</span></p>
<p>JavaFX first and foremost will be a scripting language like Adobe&#8217;s ActionScript, which allows programming to be run in the Flash Player. Likewise, JavaFX will serve the same function as JavaScript, used to power the interactive user applications in the browser window built with Ajax.</p>
<p>JavaFX also will have a timeline sequence engine, something like the one pioneered by Adobe&#8217;s Flash, that will allow animations and coordination of a multimedia sound and video roll out.</p>
<p>But even more important, perhaps, JavaFX is a bid by Sun to coordinate powerful back-end programming on a multiprocessor server with an engaging and rich presentation for the end user. All three &#8212; Sun, Adobe, and Microsoft &#8212; still have issues in pulling together the power of the Internet server and the presentation to the user. Think of the difference between bumping your way through Web pages versus the enveloping action of a computer game. Sun thinks it&#8217;s going to win the arms race to coordinate the two.</p>
<p>Sun expects to give developers the option of producing user interfaces for Web applications that run inside the browser window, or outside on the user&#8217;s normal computer desktop work space. It can do this because it will have a plug-in for the browser that updates the Java Virtual Machine, resident on many PCs. That JavaFX runtime exists in Java Standard Edition 6, update 10, and will gradually be added to existing Java Virtual Machines through an automated update process, Singh said.</p>
<p>At the same time, JavaFX applications will have the ability to migrate out of the browser window. The icon for a JavaFX application, once it&#8217;s been downloaded, can be moved onto the user&#8217;s desktop and run there through the usual drag-and-drop method. The application, unlike most that are streamed down to the browser, can be either run while connected to the Internet or stored and saved as a permanent addition, available to run when the user is disconnected. Online application suppliers have been struggling with that issue &#8212; what to do when the user is no long plugged into the Net.</p>
<p>But there&#8217;s still the issue of simplicity of application building. &#8220;Designers for end-user interfaces want to assemble content, not program it. We start from a strength among programmers, but we will produce incremental tools that allow designers to make the front end more enticing. We need to bring both of these communities together,&#8221; Singh said.</p>
<p>Exactly how that &#8220;bringing together&#8221; will proceed will await the first software development kit Sun can produce for FX this fall. Will it also be able to produce &#8220;assembly oriented&#8221; content tools, the way Adobe has?</p>
<p>In a demonstration Tuesday that needed to be restarted twice, Sun illustrated a mashup JavaFX application. A user&#8217;s collection of Facebook and Flickr pictures were loaded into the application, then a sophisticated flocking algorithm applied. If the user entered a person&#8217;s name, all the pictures with that person in them began to flock together out of a slowly moving mass on the screen. Pictures with similar colors could be enticed to flock together, etc. It was a combination of programming and presentation that many in the audience hadn&#8217;t seen before.</p>
<p>Whether they will see it on their own computers will depend on how fast Sun can deliver the goods and whether they will be able to perform as expected.</p>
<p>&#8220;We are focused on strengthening the designer/developer integration,&#8221; claimed Singh. The flocking demo illustrated Sun&#8217;s programming skills. The scripting code behind it had been compiled and could run fast enough in the Java Virtual Machine to keep everything in motion. Most scripting or &#8220;dynamic&#8221; languages wouldn&#8217;t have been equal to the feat; they must go through an interpreter, and interpreted code is slower than compiled code.</p>
<p>As Sun produces JavaFX for the desktop, it hopes to capitalize on its capabilities by following up with JavaFX for mobile devices in the spring of 2009. Java already has a strong presence in the cell phone and mobile device market.Nokia (NYSE:  <a href="http://www.techweb.com/financialCenter/index.jhtml?Account=techweb&amp;Page=QUOTE&amp;Ticker=NOK" target="_blank" class="stockLink">NOK</a>) representatives say more than half of all their phones &#8212; not just their smartphones but all their mobile device inventory &#8212; run Java now. If JavaFX gets a toehold on the desktop, Sun may outsprint the competition in offering capabilities for rich Internet applications on mobile devices.</p>
<p>If advertising, for example, could be inserted into an Internet server&#8217;s response to a user, based on what that user wanted to do with a running application, such coordination might yield competitive advantage. It already can be done in various clunky Internet applications, but that&#8217;s not the point. The point, said Singh, is &#8220;how seamlessly all the pieces can be overlaid with each other.&#8221;</p>
<p><span id="articleBody"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/05/09/sun-plans-javafx-for-the-desktop/feed/</wfw:commentRss>
		<slash:comments>319</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
