Posts

Showing posts from December, 2011

Struts 2 - How to get session in an action class that do not implement SessionAware interface

Sometime, we are not interested to implement SessionAware interface to let Struts 2 framework auto set the session map. Here is how we can get the session map in struts 2 Action class. In your Struts 2 action's execute or some other method, you can get session map like this: Map sessionMap = ServletActionContext.getContext().getSession();

In Struts 2 - Where to Put Frequently Used Options Lists

Image
Instead of populating your options lists in Action under populate() method. Put them in application scope, so that lists are not created on each call to an action. This is specially true if your option lists is being used on multiple forms. Such options lists include Countries, Products, Cities, etc. These rarely change in application life cycle. And if change is required, you can update the application scope object. If we do not use centralized approach, we have to do something like this in our JSP page. <s:select name="country" list="countries"/> And in Action class we must define a countries list, like this: private List<String> countries; public List<String> getCountries() { return countries; } public void setCountries() { countries = new ArrayList<String>(); countries.add("Germany"); countries.add("India"); countries.add("US"); countries.add("Russia"); // .... } In execute() or populate() m

How To Stop Programs That Automatically Start On Windows Startup

Image
In this post you will learn how to disable or stop programs/softwares that automatically run when Windows starts or boot. There may be some programs that you would prefer to start yourself e.g. Skype. But often there are lot of other programs that also start when Windows boot. It happen because, when you install new softwares, they may automatically put themselves in the auto-start list of Windows. This happens for following reasons: A programs might auto start itself, so that it could remain connected with their manufacturer and report you when its new edition is available. Sometime programs auto start so that you can experience fast load / opening time when you click at some icon to actually start it e.g. Acrobat Reader, Winzip, Media Player may do so. These programs may be virus and reporting how you are using your system, or what keys you press on your keyboard to third party. It may steal some important info. Let us see how you can Stop these programs to auto start, when Windows b

Moving back from Wordpress to Blogger

I starting to blog at Blogger in about 2007. With time, discovered that most good blogs use Wordpress. So without any reason, I registered a domain (bitspedia.com), and got a hosting for it, so started with Wordpress. In start, it was good time, so many plug-ins, full access to code, database to modify anything as I like. It was very nice experience. But recently I switched back to Blogger, for following reasons: I must have to add new plug-ins into Wordpress to make it secure, flexible, and looks good. So I found myself spending more time on blog management instead of writing actual contents. Unfortunately, the hosting company I selected was not satisfactory. Most time, I faced the very long loading time, and sometime no opening at all. Sometime It show "Could not establish database connection" error. Yes, this my my fault to select a poor host. But at Blogger I don't need to select any. I am not a professional Blogger (yet), so I was earning nothing from my blog. But wa

How to Install GIT Server on CentOS/Linux and Configure with Apache

Git Server Installation 1. Yum install git git-daemon (If git is not available through yum, install rpmforge repo from http://pkgs.repoforge.org/rpmforge-release/rpmforge-release.*.rpm) 2. mkdir <git directory> 3. cd <git directory> 4. git init Configure Apache with GIT Server <VirtualHost *:80>         ServerName git.bitspedia.com         DocumentRoot /git         <Directory /git/>                 DAV On                 Options ExecCGI FollowSymLinks Indexes                 # Deny everyything here                 Deny from all                 AuthType Basic                 AuthName "git repository"                 AuthUserFile /etc/httpd/htpasswd.git         </Directory>         <Directory /git/<dir-name>/<project repo>                 Allow from all                 Order allow,deny                 <Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>                         Require user <allowed user>    

How to Add Multiple Jar Files in Classpath to Run Java Program

When we run a Java program that uses some classes from external jars without updating the classpath, it throws NoClassDefFoundError. Here is how we can add JAR libraries which are located in some other folder to "java" command: C:\java-data>java  -classpath  C:\myJarLibs\*; C:\java-data   com.bitspedia.Hello In above command, the package of Hello.class is com.bitspedia and "com" folder is located in "C:\java-data\"

Facebook for a Business Mind

Image
I read many times that Facebook helps getting new customers but I never understood whats does it mean and how to do so. The most articles I read didn't explained the Facebook potential as it should be or it was done in very technical terms, that a common citizen can't understand. Earlier, my understanding was, as Facebook allows to display ads, so people display ads and get new customers (as done on TV, Newspapers, Google ads, etc. - no big deal). After all, if its about sending a new product brochures to friends, then how its different to email. But now I understand what the Social Media is all about! First I will explain in-brief the 'science' behind social media, then we will see how a business mind can use it to get some benefit. Human Behaviour - The Science Behind Social Media You must understand what is psychology behind Social Media, to get some business benefit. The primary reason of Social Media success is not technical, it about human behaviour and psychology

How to Implement Multiple Inheritance in Java

Java do not support direct multiple inheritance, we need to use interfaces to achieve it. Lets assume, we have two robots Walker and Flyer. Walker only walk, and Flyer can only Fly. [java]public interface Walker{ public walk(); } public interface Flyer{ public fly(); }[/java] Say, the company has created another robot, lets call it AllRounder, which can walk, fly, swim and run. We have already Walker and Flyer, so how we can use earlier written code using inheritance. This is how it goes ... [java]public class AllRounder implements Walker, Flyer { public walk() { // write code, how AllRounder walk } public fly() { // write code, how AllRounder fly } public run() { // write code, how AllRounder run } public swim() { // write code, how AllRounder swim } } // end of class [/java] The wise question is, what if AllRounder walk and fly in the same way our earlier robots do. Then we should not redefine walk and fly behavior in AllRounder class but use earlier written implementation. We can ac

How to Make Financial Projections using Google Adsense

Image
About this post: Last days I prepared financial projections for a business plan. I searched internet, but could not find any ... After I have make it,  I thought to share. Google lets publishes to serve ads at their sites, the ads serving and management system working behind is called Google Adsense. Before presenting Adsense forecasts, I want to briefly describe a few terms, concepts, and rules that are used in Adsense. One must know these fundamentals to understand the presented forecasts. Page Impressions:  It is a count of how many times Adsense script was processed on a page that display ads. For general understanding, we may think it as number of page views in specific time period (although details encompass little differences). Page Impression Increase:  This is my estimation of Page Impressions’ percent increase in the current specified period as compare to last period (i.e. a month or year). Effective Cost Per 1000 Impressions (eCPM):  It is also called Cost Per Mile, a very i

Effects of Social Media and High-Tech Overuse

Image
There are two dimensions of the survey. First: to what extent the social networks and high-tech overuse[1] and frustration exist. Secondly, what effects it leaves on human nature and behaviour. Lets look at the survey results first : I share a few comments of survey participants: "Mostly on social networks we are just wasting our time because their is nothing new after an hour of standing on site." "Technology is making us humans increasingly dependent upon machines. Physical exertion is decreasing. It is adversely affecting our healths." "Facebook is an addiction and I waste most of my time in winning or loosing arguments/comments fights over facebook." "The survey results would be interesting and might help people in making better use of these technologies." "Now a days facebook offers some social games, like farmville and cafeworld, in which you can not only play your game to achieve next levels, but can also compare your performance with

Entrepreneurship Lessons from Rozee.PK

Image
LUMS organized TiE Khudee Competition in 2008, in which people from all Pakistan were invited to send their business ideas. They selected a few team after evaulating their ideas and business plans’ executive summary. We (I with my friend, Umar) were one of them. All teams were offered 5 days workshop on entrepreneurship to facilitate writing final business plan. Ok, I keep it short. The CEO of Naseeb Networks was their at workshop as entrepreneurship trainer and guest speaker, named Monis Rehman. Rozee.pk is his own idea and a product of Naseeb Networks. At workshop, he shared his success story of Rozee.pk that contains a really great lesson (that I infact realized later). He told, he was an electronics engineer at Intel and member of 386 processor design team. He was use to using different job sites at US. So, when returned to Pakistan, he searched job sites to apply for the job. He come to know there was no such job portal but one that owns extremely low quality. He was just fed up b

High Traffic Websites Written in Java

Here are some high traffic sites/apps written in Java based technologies: 1. LinkedIn, Read  here 2. TripAdvisor.com. Read  here 3. Ebay.com, Read  here  and  here 4. Amazon.com, Read  here 5. Mailinator.com. Read  here 6. Google Talk, Read  here 7. Feedburner.com, Read  here 8. AliBaba.com, Read  here

How Much One Can Earn From A Facebook App

I was very curious knowing how much one can earn from a facebook app. I come up, the earning from Facebook app depends on following factors: 1. How many active users you app have. Active users are those who use your app daily, for example if you have 20,000 users but only 1000 use it daily, the active users are 1000. 2. In which economy (or country) your facebook app users are. Here are some facts shared by a very successful Facebook apps developer, "1. If your apps can attract around 1000 unique users per day with atleast 60 % from High earning countries(HEC) like Autralia, US, UK and Canada , you can make around 10$ per day. 2. 10000 unique users with 60-70% from HEC will earn you around 40-50$ per day 3. 15000 unique users —> 90-100$ per day 4. 35000 unique users —> 150-200$ pd 5. 45000 unique users —-> 250-350$ pd 5. 60000 unique users —-> 400-600$ pd 6. 1.2 lakhs unique users— 1000-1500$ pd" Reference: udayogra.com

How to hide facebook friends from friends

Image
There is big change in process to hide friends if you are using timeline view. I really have to spend 10 minutes to search how to hide Facebook friends from friends after putting ON timeline.  Here are the steps. 1. Click on  Update Info  at your Profile View 2. At Edit page, choose  Friends 3. Click on  Edit  and choose  Only Me Hope it helped!

How to Install OpenBravo ERP on Windows

Image
I have just installed Open Bravo ERP (OpenbravoERP_2.40-windows-installer). Here is how I proceeded. OpenBravo requires  JDK ,  Ant ,  Tomcat ,  PostgreSQL . You can install these applications before starting OpenBravo installation or during the installation (I downloaded and installed during OpenBravo installation). Just start the OpenBravo installation wizard and choose “next” .. “next” … you know. OpenBravo installation wizard ask for following: JDK Download and install Ver. 1.5 or later. Wizard will automatically detect where it is installed. (or locate it, if it ask). Ant Download and install When OpenBravo wizard asks for it, select  ant-installation-dir /bin/ant.bat ) Tomcat Download and install Select the  installation-dir . when wizard asks for it. PostgreSQL (so that OpenBravo can install ERP database on it) Download and Install PostgreSQL (simple “next”, “next” process). Choose and remember password and port number (5432 default) which you configure during installation proce

Choice of Programming Language for Different Softwares

With experience and reading things around, here I share some patterns, I see about, what programming language is being used for what type of software. C  ... When we need to write some base infrastructure that will be used by some upper layers softwares. This is when no compromise on performance is accepted. For such software middle-ware or virtual machine oriented languages are not good choice, as it would only add an extra layer. And software will not compile in machine native code. For example databases, operating systems, device drivers, etc are mostly written in C/C++ etc. MySQL, Linux, Windows (most part) are all written in C for the same reason. Java  ... Java is best choice for writing bigger softwares that organization need to run their processes (e.g. warehouse, sales, etc.). These softwares are mostly know as enterprise softwares or ERPs. One might think, why not write such software in C, as performance is also paramount for ERPs. Yes, it is right but a bigger reality is eve

Source of Ideas for New Features of a Software

So you are writing some application, or building something new. One of the fundamental source of ideas for new features are the people who are most close to your product. In case of soft products, these are  users  and  developers  (they are in-touch with your live product, more than you). They know well, what the product should offer next, that can be the next killer feature. But for it, you should must give them an environment, respect and service, that they love to share with you. Read a conversation with  Werner Vogels  (Amazon CTO), how they have make strategy to involve developers and clients for development directions and better service. Google itself uses  Google Moderator , to let users share new ideas for a particular product which other users vote for. So in this way they can just pick the top new feature ideas and implement.

80% Traffic, Hit Only 20% of Website Features

Couple of months earlier, I worked on a web project. We implemented a lot of features, specifically in admin area. But after launch, what I see is, only 20% of the features are being used by 80% of the users. It convinced me, we must make and release small features as fast as possible and plan the roadmap with market feedback. It remind me, Pareto Principle, which stats that " roughly 80% of the effects come from 20% of the causes " ...  for example,  20% of the software functions are used 80% of the time i.e.  80% users used only 20% of a software (just analyse you usage of MS Word, for example) And, If there is 100 lines of code snippet facing performance bottlenecks. There are only about 20 lines that need optimization.  Even Microsoft noted,  when they removed 20% of the most reported bugs, 80% crashes were removed. Its so beautiful and great lesson for me. I can visualize it very deeply.

How to stop a browser to cache a web page or ajax-response in java web appplications

In my recent web project, my pages were working well. But one of ajax call response was not working correctly. I figured out, the response I was getting was a cache copy returned by browser. If you are in same situation or wish the browser do not cache a particular web page or an ajax response. Here is the solution: Just set "Cache-Control" header to "no-cache", in HttpServletResponse, like this: response.setHeader("Cache-Control", "no-cache");

Web Business Models

In my opinion, these are the primary web business models, which are followed by some of the highly successful websites. Marketplace Model , This is one of highly profitable model, because it directly deliver some financial (or other) benefit to both involved parties which connect through it. This model connect the sellers and buyers. All Free Lancing, B2B, B2C protals comes under this category. Example of web sites following marketplace web business model are  eBay.com ,  oDesk.com ,  AliBaba.com , etc. Community-Driven Model , The contents of websites which follow the community-driven web business model are filled or populated by its users. The example sites include:  StackOverflow.com  and  Wikipedia.com , etc. In addition idea and implementation of a community-driven web product, its more important to answer a fundamental question - why users would give their time to add contents? If you can't somehow convince users to give your site sometime and great knowledge, you can't b