<?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>YourSearchBuddy &#187; Technology</title>
	<atom:link href="http://www.yoursearchbuddy.com/category/technology/feed" rel="self" type="application/rss+xml" />
	<link>http://www.yoursearchbuddy.com</link>
	<description>your search ends here</description>
	<lastBuildDate>Sun, 16 Jun 2013 15:30:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Get the IP address in ASP.NET</title>
		<link>http://www.yoursearchbuddy.com/ip-address-aspnet</link>
		<comments>http://www.yoursearchbuddy.com/ip-address-aspnet#comments</comments>
		<pubDate>Tue, 14 May 2013 20:45:52 +0000</pubDate>
		<dc:creator>lokeshlal</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[TipnTricks]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ip]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=9339</guid>
		<description><![CDATA[To get the ip address of client machine in asp.net use the following code snippet. private string GetUserIP() { string ip = Request.ServerVariables["HTTP_X_CLUSTER_CLIENT_IP"]; string trueIP = string.Empty; if (!string.IsNullOrEmpty(ip)) {... <a class="meta-more" href="http://www.yoursearchbuddy.com/ip-address-aspnet">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To get the ip address of client machine in asp.net use the following code snippet.</p>
<pre>
private string GetUserIP()
{
    string ip = Request.ServerVariables["HTTP_X_CLUSTER_CLIENT_IP"];
    string trueIP = string.Empty;
    if (!string.IsNullOrEmpty(ip))
    {
        trueIP = ip;
    }
    else
    {
        ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (!string.IsNullOrEmpty(ip))
        {
            string[] ipRange = ip.Split(',');
            trueIP = ipRange[0];
        }
        else
        {
            trueIP = Request.ServerVariables["REMOTE_ADDR"];
        }
    }

    return trueIP;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/ip-address-aspnet/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook style mention</title>
		<link>http://www.yoursearchbuddy.com/facebook-style-mention</link>
		<comments>http://www.yoursearchbuddy.com/facebook-style-mention#comments</comments>
		<pubDate>Tue, 23 Apr 2013 16:11:49 +0000</pubDate>
		<dc:creator>lokeshlal</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[TipnTricks]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[mention]]></category>
		<category><![CDATA[Tag]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8929</guid>
		<description><![CDATA[I was working on Facebook style mention and found this link http://stackoverflow.com/questions/8438371/style-text-inside-textarea-like-facebook-does this gives me initial setup, for css and html. later I added script to make it work. Added... <a class="meta-more" href="http://www.yoursearchbuddy.com/facebook-style-mention">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was working on Facebook style mention and found this link</p>
<p><a href="http://stackoverflow.com/questions/8438371/style-text-inside-textarea-like-facebook-does">http://stackoverflow.com/questions/8438371/style-text-inside-textarea-like-facebook-does<br />
</a><br />
this gives me initial setup, for css and html. later I added script to make it work.</p>
<p>Added attributes to maintain the <strong>mentions</strong> in the main textarea element and script to sync the underlying div and upper textarea.</p>
<p>basically underlying div is use to style the textarea text.</p>
<p>here is the html file.</p>
<pre>
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Demo&lt;/title&gt;
&lt;script type="text/javascript" src="http://sandbox.tozoy.com/javascripts/jquery.min.js"&gt;&lt;/script&gt;
&lt;style&gt;
* { font-family: sans-serif; font-size: 10pt; font-weight: normal; }
.txtwrapper     { position: relative; width: 200px; height: 35px; }
.txtwrapper &gt; * { position: absolute; top: 0; left: 0; height: 100%; width: 100%; margin: 0; padding: 0; }
.highlighter { background-color: #fff; color: #fff; width: 100%; height: 100%;}
.highlight   { background:#d8dfea;background:-webkit-gradient(linear, center top, center bottom, from(#dce6f8), to(#bdcff1));background:-webkit-linear-gradient(#dce6f8, #bdcff1);-webkit-border-radius:2px;-webkit-box-shadow:0 0 0 1px #a3bcea;font-weight:normal; color: transparent;}
.txtwrapper &gt; textarea     { background-color: transparent; border: 0;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body onload="init();"&gt;
&lt;div class="txtwrapper"&gt;
	&lt;div class="highlighter"&gt;
		&lt;span class="highlight"&gt;lokesh lal&lt;/span&gt; and &lt;span class="highlight"&gt;vishal gupta&lt;/span&gt; are working on tozoy
	&lt;/div&gt;
	&lt;textarea onkeyup="hh(this);" tagsname="|Lokesh Lal|Vishal Gupta" tagsdata="|1234567|3456768"&gt;lokesh lal and vishal gupta are working on tozoy&lt;/textarea&gt;
&lt;/div&gt;
&lt;script&gt;

function hh(obj)
{
	var highlighter = $(obj).parent().find('.highlighter').eq(0);
	var s = $(obj).val();
	var tagsnamearr = $(obj).attr('tagsname').split('|');
	var tagsdataarr = $(obj).attr('tagsdata').split('|');
	for(var i = 0 ; i &lt; tagsnamearr.length; i++) {
		if(tagsnamearr[i] == '')
			continue;
		var idx = s.search(new RegExp(tagsnamearr[i], "i"));
		var len = tagsnamearr[i].length;
		if(s.search(new RegExp(tagsnamearr[i], "i")) &gt; -1) {
			s = s.replace(new RegExp(tagsnamearr[i], "i"),'&lt;span class="highlight" tagname="' + tagsnamearr[i] + '" tagdata="' + tagsdataarr[i] + '"&gt;' + s.substr(idx,len) + '&lt;/span&gt;');
		}
	}

	while(s.indexOf("  ") &gt; -1)
		s = s.replace("  "," ");

	highlighter.html(s);

	var s1 = $(obj).val();
	while(s1.indexOf("  ") &gt; -1)
		s1 = s1.replace("  "," ");
	$(obj).val(s1);

	//update the tagsname and tagsdata

	var tagsdata = $(obj).attr('tagsdata').split('|');
	var tagsname = $(obj).attr('tagsname').split('|');
	var newtagsdata = ''
	var newtagsname = ''
	for(var i = 0; i &lt;  tagsdata.length; i++) {
		var isExists = false;

		if(tagsnamearr[i] == '')
			continue;
		for(var j = 0 ; j &lt; $(obj).parent().find('.highlight').length; j++)
		{
			if($(obj).parent().find('.highlight').eq(j).html().toLowerCase() == tagsname[i].toLowerCase()) {
				isExists = true;
			}
		}
		if(isExists == true) {
			newtagsdata = newtagsdata + '|' + tagsdata[i];
			newtagsname = newtagsname + '|' + tagsname[i];
		}
	}

	$(obj).attr('tagsdata', newtagsdata)
	$(obj).attr('tagsname', newtagsname)

}
var observe;
if (window.attachEvent) {
    observe = function (element, event, handler) {
        element.attachEvent('on'+event, handler);
    };
}
else {
    observe = function (element, event, handler) {
        element.addEventListener(event, handler, false);
    };
}
function init () {
    function resize () {

		$('textarea').each(function(i){
			$('textarea')[i].style.height = 'auto';
			$('textarea')[i].style.height = $('textarea')[i].scrollHeight+'px';

			$('textarea').eq(i).parent()[0].style.height = 'auto';
			$('textarea').eq(i).parent()[0].style.height = ($('textarea')[i].scrollHeight + 9)+'px';

			//setupBlocks();

		});
    }
    /* 0-timeout to get the already changed text */
    function delayedResize () {
        window.setTimeout(resize, 0);
    }
	$('textarea').each(function(i){
		observe($('textarea')[i], 'change',  resize);
		observe($('textarea')[i], 'cut',     delayedResize);
		observe($('textarea')[i], 'paste',   delayedResize);
		observe($('textarea')[i], 'drop',    delayedResize);
		observe($('textarea')[i], 'keydown', delayedResize);
	});
    //text.focus();
    //text.select();
    resize();
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/facebook-style-mention/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Teens are tiring of the social network</title>
		<link>http://www.yoursearchbuddy.com/teens-tiring-social-network</link>
		<comments>http://www.yoursearchbuddy.com/teens-tiring-social-network#comments</comments>
		<pubDate>Tue, 23 Apr 2013 00:11:46 +0000</pubDate>
		<dc:creator>artisajjan</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Information]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[instagram]]></category>
		<category><![CDATA[teen]]></category>
		<category><![CDATA[teenagers]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8927</guid>
		<description><![CDATA[Teenagers are a good measure of what&#8217;s &#8220;cool.&#8221; Observing which apps they use and how they interact with technology can help the rest of us spot budding trends. Facebook has... <a class="meta-more" href="http://www.yoursearchbuddy.com/teens-tiring-social-network">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Teenagers are a good measure of what&#8217;s &#8220;cool.&#8221; Observing which apps they use and how they interact with technology can help the rest of us spot budding trends. Facebook has made the startling admission that teenagers are becoming bored with the social networking giant.</p>
<p>Facing competition from younger, more agile and &#8216;cooler&#8217; apps such as Snapchat and Instagram, Facebook fears its long-term business could be harmed.</p>
<p>Why isn&#8217;t Facebook &#8220;cool&#8221; anymore? The Verge&#8217;s Ellis Hamburger asked a few social media experts for their thoughts.</p>
<p>&#8220;I think it has less to do with kids consciously looking for &#8216;the next big thing&#8217; than Facebook just no longer being a space that serves them,&#8221; one said. In other words, it used to be &#8220;cool&#8221; to brag about yourself and show pictures to friends on Facebook. Now people are looking for more intimate places to share items with a handful of people, like Snapchat. There&#8217;s a sense of privacy there, and it meets a need Facebook has grown too big to serve.</p>
<p>Of course, this doesn&#8217;t mean teens are deleting their Facebook profiles. They&#8217;re just looking to use the service less, and they&#8217;re open to communicating on other platforms.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/teens-tiring-social-network/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Samsung&#8217;s New Phone Starting Next Week</title>
		<link>http://www.yoursearchbuddy.com/samsungs-phone-starting-week</link>
		<comments>http://www.yoursearchbuddy.com/samsungs-phone-starting-week#comments</comments>
		<pubDate>Mon, 22 Apr 2013 23:47:23 +0000</pubDate>
		<dc:creator>artisajjan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Information]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[galaxy]]></category>
		<category><![CDATA[S4 galaxy]]></category>
		<category><![CDATA[samsung]]></category>
		<category><![CDATA[Samsung S4]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8925</guid>
		<description><![CDATA[Samsung&#8217;s Galaxy S4 has become the Android phone to wait for. The phone has a slew of new features, including an improved 13-megapixel camera, new software features and it responds... <a class="meta-more" href="http://www.yoursearchbuddy.com/samsungs-phone-starting-week">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Samsung&#8217;s Galaxy S4 has become the Android phone to wait for. The phone has a slew of new features, including an improved 13-megapixel camera, new software features and it responds to waves and gestures. It also has a 5-inch Super AMOLED 1080p screen. </p>
<p>The release of Samsung&#8217;s next super smartphone, the Galaxy S4, is just days away</p>
<p><strong>Verizon Wireless</strong><br />
When: May, with exact date to come.<br />
Price: To be announced</p>
<p><strong>AT&#038;T</strong><br />
When: AT&#038;T promised an official ship date of April 30, but some devices may ship earlier. You can pre-order now.<br />
Price: $199 for the 16GB version (with a two-year contract)</p>
<p><strong>T-Mobile</strong><br />
When: April 24<br />
Price: $149.99 down; subsequent monthly service payments should be $20<br />
<strong><br />
U.S. Cellular</strong><br />
When: Second week of May. You can pre-order now.<br />
Price: $199 for the 16GB version (with a two-year contract)</p>
<p><strong>Sprint</strong><br />
When: April 27.<br />
Price: $249 for the 16GB version (with a two-year contract); new customers can get the smartphone for $149</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/samsungs-phone-starting-week/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Samsung Galaxy S4 vs Apple iPhone 5</title>
		<link>http://www.yoursearchbuddy.com/samsung-galaxy-s4-apple-iphone-5</link>
		<comments>http://www.yoursearchbuddy.com/samsung-galaxy-s4-apple-iphone-5#comments</comments>
		<pubDate>Tue, 19 Mar 2013 00:03:18 +0000</pubDate>
		<dc:creator>artisajjan</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Mobile phone]]></category>
		<category><![CDATA[samsung]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8685</guid>
		<description><![CDATA[Like Apple, Samsung is a hardware company that innovates mainly through software The Samsung Galaxy S4 is expected to have a full-HD 1920×1080 display (up from 1280×720 on the S3)... <a class="meta-more" href="http://www.yoursearchbuddy.com/samsung-galaxy-s4-apple-iphone-5">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Like Apple, Samsung is a hardware company that innovates mainly through software</p>
<p>The Samsung Galaxy S4 is expected to have a full-HD 1920×1080 display (up from 1280×720 on the S3) — and the display might even make the jump from 4.8 inches to an edge-to-edge 5 inches.</p>
<p>The 5-inch full HD Super AMOLED; 1,920×1,080 screen, at 441 pixels per inch, is both bigger and higher resolution than the iPhone 5.</p>
<p>The resolution of the 7.9mm Galaxy S4 is higher than the iPhone 5.</p>
<p>The Gorilla Glass 3 – the first device to sport the new technology – is ostensibly stronger than what iPhone 5 has</p>
<p>Inside, the Samsung Galaxy S4 is a near 2 GHz quad-core CPU. The dual-core iPhone 5 has 1 GHz of power.</p>
<p>Samsung stuffed a 13 megapixel camera into the Samsung Galaxy S4, while the iPhone 5 tops out at 8MP.</p>
<p>Samsung is also starting to use NFC is interesting ways: letting people pair the phones by tapping and then turning the ad-hoc connection between multiple phones into a surround sound system. That’s quite cool, though it also seems pretty impractical.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/samsung-galaxy-s4-apple-iphone-5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create basic wordpress plugin</title>
		<link>http://www.yoursearchbuddy.com/how-to-create-basic-wordpress-plugin</link>
		<comments>http://www.yoursearchbuddy.com/how-to-create-basic-wordpress-plugin#comments</comments>
		<pubDate>Mon, 28 Jan 2013 08:36:15 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[How to?]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[create wordpress plugin]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8108</guid>
		<description><![CDATA[There are many things that you can do with your wordpress plugin to enhance your website that can also be used by other website owners. In this post we will... <a class="meta-more" href="http://www.yoursearchbuddy.com/how-to-create-basic-wordpress-plugin">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are many things that you can do with your wordpress plugin to enhance your website that can also be used by other website owners. In this post we will go through a very basic wordpress plugin and then in other posts i will show some advanced options like admin panel and all.</p>
<p>Create a folder with typically your plugin name. Inside that folder create a php file (i would give it my plugin name again). WordPress actually doesn&#8217;t care about the file names. You need to specify in your php file what file should be considered as the main file for wordpress to consider.</p>
<p>So in my case i created a folder test and inside test i created a file test.php. In my test.php i added this code:</p>
<pre>&lt;?php
	/*
	Plugin Name: Test Plugin
	Plugin URI: http://www.testplugin.com
	Description: Plugin to test how plugins work
	Author: My Name
	Version: 1.0
	Author URI: http://mysite.com
	*/

	require_once('action.php');
	require_once('admin.php');

	if(is_admin()){
                <strong>//this will add a menu item for this plugin in the admin panel</strong>
		add_action('admin_menu', 'admin_menu');
	}
?&gt;</pre>
<p>Add these information according to you: Plugin Name, Plugin URI, Description, Author, Version, Author URI</p>
<p>I am calling two php files from test.php. admin.php for admin options for website owners and action.php to do what you want your plugin to do.</p>
<p><strong><span style="text-decoration: underline;">admin.php</span></strong></p>
<pre>&lt;?php
	/*
	The main admin page for this plugin.
	*/

	function admin_register_head() {
		$siteurl = get_option('siteurl');
		$url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/style.css';

		//specify css file to use for plugin's admin section
		echo "&lt;link rel='stylesheet' type='text/css' href='$url' /&gt;\n";
	}

	//function to call citrix_twitter_feed_admin_page()
	function admin_menu(){
		add_options_page('Test Plugin', 'Test Plugin', 'manage_options', 'test-feed', 'admin_page');
		//check here to see how to use <a href="http://codex.wordpress.org/Function_Reference/add_options_page" target="_blank">add_options_page</a>

		add_action('admin_head', 'admin_register_head');
	}

	function admin_page(){
		echo "put test() in your post to use plugin.";
	}
?&gt;</pre>
<p>In admin.php, <strong>add_options_page</strong> is called to display what to do in the admin panel by calling <strong>admin_page()</strong></p>
<p>Also in admin_menu() add_action hook is called to specify css used for the admin section. In my next post i will show some advanced options for admin section.</p>
<p>Because this is very basic plugin, we are not letting users customize this plugin and only displaying that they should put test() in their post to use this plugin.</p>
<p><strong><span style="text-decoration: underline;">action.php</span></strong></p>
<pre>&lt;?php
	/*
	This is where all the code is written that plugin actually does
	*/

	function test() {
		echo "This is my first basic plugin";
	}
?&gt;</pre>
<p>So, now if anyone activate this plugin and put test() in their post, it will display &#8220;This is my first basic plugin&#8221;.</p>
<p>Don&#8217;t forget to leave comments if you have any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/how-to-create-basic-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create Download File button using Java Servlets</title>
		<link>http://www.yoursearchbuddy.com/create-download-file-button-java-servlets</link>
		<comments>http://www.yoursearchbuddy.com/create-download-file-button-java-servlets#comments</comments>
		<pubDate>Mon, 28 Jan 2013 02:18:24 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[How to?]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[download button java servlet]]></category>
		<category><![CDATA[download image java servlet]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java servlet]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8104</guid>
		<description><![CDATA[Before you read this post i would recommend you to go through these earlier post to understand what we did and what we are going to do. Convert SVG to... <a class="meta-more" href="http://www.yoursearchbuddy.com/create-download-file-button-java-servlets">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Before you read this post i would recommend you to go through these earlier post to understand what we did and what we are going to do.</p>
<p><strong><a href="http://www.yoursearchbuddy.com/convert-svg-png-java-servlet">Convert SVG to PNG using Java Servlet</a></strong></p>
<p><strong><a href="http://www.yoursearchbuddy.com/java-servlets-ajax">How to use Java Servlets and Ajax</a></strong></p>
<p>I would tell you what we did in earlier post. We converted SVG to PNG and stored on the server. Now i want to have a download image button on my page so that users can download it on their machine rather than tricks like &#8220;Ctrl+S&#8221;.</p>
<p>So for this purpose i will create a new Java Servlet and call it download.java</p>
<p>On my index.jsp i will have a download button that will send the image name to download.java and it will do the rest. I will send image name with the URL, so i will write my code in doGet method.</p>
<p>1) A simple download button on index.jsp (i am hard coding the image name, but you can program it as well)</p>
<pre>
&lt;a href='download?img=final.png'&gt;Download file&lt;/a&gt;
</pre>
<p>2) download.java</p>
<pre>
/**
 * Servlet implementation class saveimage
 */
@WebServlet({ "/saveimage", "/saveimage/*" })
public class saveimage extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final int BYTES_DOWNLOAD = 1024;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public saveimage() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String img_name = request.getParameter("img");

		// Set the headers.
		response.setContentType("application/x-download");
		response.setHeader("Content-Disposition", "attachment; filename=" + img_name);

		InputStream URI_input = getServletContext().getResourceAsStream("assets/output/" + img_name);

		int read=0;
		byte[] bytes = new byte[BYTES_DOWNLOAD];
		OutputStream os = response.getOutputStream();

		while((read = URI_input.read(bytes))!= -1){
			os.write(bytes, 0, read);
		}
		os.flush();
		os.close();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}

So, now after user will click on "Download File" link a popup will be there to save image anywhere on their machine.

Keep checking for more tutorials.
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/create-download-file-button-java-servlets/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Java Servlets and Ajax</title>
		<link>http://www.yoursearchbuddy.com/java-servlets-ajax</link>
		<comments>http://www.yoursearchbuddy.com/java-servlets-ajax#comments</comments>
		<pubDate>Mon, 28 Jan 2013 02:03:40 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[How to?]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java servlets]]></category>
		<category><![CDATA[java servlets ajax]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8097</guid>
		<description><![CDATA[In previous post we saw an example of how to convert SVG to PNG using Java Servlet. You can either use a submit button to submit form to servlet or... <a class="meta-more" href="http://www.yoursearchbuddy.com/java-servlets-ajax">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.yoursearchbuddy.com/convert-svg-png-java-servlet"><strong>previous post</strong></a> we saw an example of how to convert SVG to PNG using Java Servlet.</p>
<p>You can either use a submit button to submit form to servlet or use AJAX instead. I personally prefer AJAX as you don&#8217;t have to leave a page and get results on the same page. </p>
<p>So lets see how we can use AJAX to pass data to Java Servlet and get result back. We will use previous example to demonstrate it. Please look at the <a href="http://www.yoursearchbuddy.com/convert-svg-png-java-servlet"><strong>this post</strong></a> to get idea of what we did earlier:</p>
<p>1) Create form in index.jsp in WebContent folder</p>
<pre>
&lt;form name="image" method="post" id="process" action="convert"&gt;
	<strong>//enter image path here. eg: assets/input/temp.svg (you can program this anyway you want to include image from list of many images etc.)</strong>
	&lt;input type="text" class="text" name="img" id="img" placeholder="img"&gt;

	<strong>//enter height of the final image you want</strong>
	&lt;input type="text" class="text" name="height" id="height" placeholder="Height"&gt;&lt;span&gt;px&lt;/span&gt;

	<strong>//enter width of the final image you want</strong>
	&lt;input type="text" class="text" name="width" id="width" placeholder="Width"&gt;&lt;span&gt;px&lt;/span&gt;

        &lt;input type="submit" value="Submit"&gt;
&lt;/form&gt;

         <strong>//converted png will be displayed here</strong>
         &lt;div class="thumbnail" id="final-image"&gt;&lt;/div&gt;

        <strong>//javascript file that is used to call AJAX when form is submitted</strong>
        &lt;script type="text/javascript" src="js/script.js"&gt;&lt;/script&gt;
</pre>
<p>2) Servlet: convert.java</p>
<pre>
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	// TODO Auto-generated method stub 

	try{
	<strong>//Step -1: We read the input SVG document into Transcoder Input</strong>
	Integer width = Integer.parseInt(request.getParameter("width"));
	Integer height = Integer.parseInt(request.getParameter("height"));
	String img_name = request.getParameter("img");

	String final_png = "final.png";
	InputStream svg_URI_input = getServletContext().getResourceAsStream(img_name);
	TranscoderInput input_svg_image = new TranscoderInput(svg_URI_input);        

	<strong>//Step-2: Define OutputStream to PNG Image and attach to TranscoderOutput</strong>
	OutputStream png_ostream = new FileOutputStream(getServletContext().getRealPath("/") + "assets/output/" + final_png);
	TranscoderOutput output_png_image = new TranscoderOutput(png_ostream);              

	<strong>// Step-3: Create PNGTranscoder and define hints if required</strong>
	PNGTranscoder my_converter = new PNGTranscoder();      

	my_converter.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
	my_converter.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height));

			<strong>// Step-4: Convert and Write output</strong>
	my_converter.transcode(input_svg_image, output_png_image);

	png_ostream.flush();
	png_ostream.close();  

	response.setContentType("text/plain");
	response.setCharacterEncoding("UTF-8");

	<strong>//send response</strong>
	response.getWriter().write(final_png);

	}catch(Exception e){
		System.err.println(e.toString());
	}

}
</pre>
<p>3) AJAX called in js/script.js</p>
<pre>
$(document).ready(function(){
/* Submit form and do ajax update */
$("#process").submit(function(){

	var error = false;
	/* Code to do validation */

	$.ajax({
		type: "POST",
		url: "convert",
		data: "item=" + img + "&#038;height=" + height + "&#038;width=" + width,
		error: function (xhr, ajaxOptions, thrownError) {
			alert(xhr.status);
			alert(thrownError);
		 },
		success: function(data){
			var file_path = "assets/output/" + data;
			var file_name = "&lt;a href='" + file_path + "' target='_blank'&gt;&lt;img name='finalImage' src= '" + file_path +"' /&gt;&lt;/a&gt;";

			$("#final-image").empty().append(file_name);
		}
	}); /* Ajax End */

	return false;
});
}); /* End ready function */
</pre>
<p>script.js gets the file name and displays on index.jsp after conversion without leaving page.</p>
<p>In the next post i will discuss how can we create a download image button using Java Servlets</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/java-servlets-ajax/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert SVG to PNG using Java Servlet</title>
		<link>http://www.yoursearchbuddy.com/convert-svg-png-java-servlet</link>
		<comments>http://www.yoursearchbuddy.com/convert-svg-png-java-servlet#comments</comments>
		<pubDate>Sun, 27 Jan 2013 12:12:43 +0000</pubDate>
		<dc:creator>techno</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[How to?]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[TipnTricks]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[batik]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java servlet]]></category>
		<category><![CDATA[svg to png]]></category>
		<category><![CDATA[svg to png batik]]></category>
		<category><![CDATA[svg to png jsp servlet]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8084</guid>
		<description><![CDATA[I am going to cover several aspects of this project in other posts. In this post i will only cover how to convert SVG to png. I will use Batik... <a class="meta-more" href="http://www.yoursearchbuddy.com/convert-svg-png-java-servlet">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am going to cover several aspects of this project in other posts. In this post i will only cover how to convert SVG to png. I will use Batik to achieve this.</p>
<p>I am assuming that you have very basic knowledge of JSP and Java Servlets.</p>
<p><strong>Project in Brief</strong>:</p>
<p>1. Send SVG info as well as the final image height and width to a servlet (the image is stored in assets/input folder)<br />
2. The servlet will convert the SVG to a png and store in assets/output folder.<br />
3) The package used for the conversion is <a href="http://xmlgraphics.apache.org/batik/download.html" target="_blank">Batik</a></p>
<p>So here we go:</p>
<p>1) Create index.jsp under WebContent. Create a form in index.jsp that posts request to servlet &#8220;convert&#8221;</p>
<pre>
&lt;form name="image" method="post" id="process" action="convert"&gt;
	<strong>//enter image path here. eg: assets/input/temp.svg (you can program this anyway you want to include image from list of many images etc.)</strong>
	&lt;input type="text" class="text" name="img" id="img" placeholder="img"&gt;

	<strong>//enter height of the final image you want</strong>
	&lt;input type="text" class="text" name="height" id="height" placeholder="Height"&gt;&lt;span&gt;px&lt;/span&gt;

	<strong>//enter width of the final image you want</strong>
	&lt;input type="text" class="text" name="width" id="width" placeholder="Width"&gt;&lt;span&gt;px&lt;/span&gt;
&lt;/form&gt;

        &lt;input type="submit" value="Submit"&gt;
</pre>
<p>2) Copy all jar files from the link above for batik package in WebContent/Web-Inf/lib folder and add then to build path.</p>
<p>3) Create a servlet &#8220;convert&#8221;. This servlet will convert SVG to png as final.png in assets/output folder</p>
<pre>
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub 

try{
Integer width = Integer.parseInt(request.getParameter("width"));
Integer height = Integer.parseInt(request.getParameter("height"));
String img_name = request.getParameter("img");

<strong>//Step -1: We read the input SVG document into Transcoder Input</strong>
InputStream svg_URI_input = getServletContext().getResourceAsStream(img_name);
TranscoderInput input_svg_image = new TranscoderInput(svg_URI_input);        

<strong>//Step-2: Define OutputStream to PNG Image and attach to TranscoderOutput</strong>
//OutputStream png_ostream = new FileOutputStream(getServletContext().getRealPath("/") + "assets/output/final.png");
TranscoderOutput output_png_image = new TranscoderOutput(png_ostream);              

<strong>// Step-3: Create PNGTranscoder and define hints if required</strong>
PNGTranscoder my_converter = new PNGTranscoder();      

my_converter.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
my_converter.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height));

<strong>// Step-4: Convert and Write output</strong>
//response.setContentType("image/png");

my_converter.transcode(input_svg_image, output_png_image);

png_ostream.flush();
png_ostream.close();
}catch(Exception e){
	System.err.println(e.toString());
}

}
</pre>
<p>Now if you go to /assets/output there will be final.png there which is the required image you want.</p>
<p>In other posts i will show how to create a download button for this image and also how to use ajax with servlets. </p>
<p>Hope you enjoyed this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/convert-svg-png-java-servlet/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Checkout for Indian Merchants</title>
		<link>http://www.yoursearchbuddy.com/google-checkout-indian-merchants</link>
		<comments>http://www.yoursearchbuddy.com/google-checkout-indian-merchants#comments</comments>
		<pubDate>Thu, 24 Jan 2013 22:05:31 +0000</pubDate>
		<dc:creator>artisajjan</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google play]]></category>
		<category><![CDATA[india]]></category>

		<guid isPermaLink="false">http://www.yoursearchbuddy.com/?p=8062</guid>
		<description><![CDATA[There’s finally cause for celebration for the mobile community in India after Google announced that it has finally enabled developers in the country to sell paid apps for Android through... <a class="meta-more" href="http://www.yoursearchbuddy.com/google-checkout-indian-merchants">Read more <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There’s finally cause for celebration for the mobile community in India after Google announced that it has finally enabled developers in the country to sell paid apps for Android through its Google Play app store.</p>
<p>Developers in India can sell paid applications, in-app products and subscriptions in Google Play, with monthly payouts to their local bank accounts. They can take advantage of all of the tools offered by Google Play to monetise their products, and they can target their products to the paid ecosystem of users in India and across the world,” wrote Ibrahim Elbouchikhi, product manager of the Google Play team, in an official Android developers’ blog post.</p>
<p><strong>Set UP</strong></p>
<p>One will have to create a developer’s profile (you can do that here), say ‘yes’ to the developer distribution agreement and pay a registration fee of $25 with credit/debit card (using Google Checkout).</p>
<p>Once done, an Android developer from India can sign in to his/her ‘developer console’ and set up a Google Checkout merchant account. </p>
<p>If one’s apps are already published as free, one can still monetise those by adding in-app products or subscriptions. </p>
<p>New apps can be published as paid ones, in addition to selling in-app products or subscriptions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yoursearchbuddy.com/google-checkout-indian-merchants/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
