Posts

Showing posts from May, 2012

How to Create a Facebook Account

Image
Hey! young man, my guess is you have heard from one of your friend or relative about Facebook. And you want to create a Facebook account. But you don't know how to create it. Here I would help you step by step to do so. Facebook is a social networking website that helps you connect with you friends. To create a new facebook account, you just need to follow these steps: 1. Before creating facebook account, you should have your own email address. If you have it, fantastic! If not, go to gmail.com and create a new email address by clicking Sign Up link. 2.  Click here  or go to http://www.facebook.com , once web page is open, at first page (it is called Home Page), you will see a form. The form looks like this: 3. So just fill the form with asked information (name, email, password, gender, date of birth), and click Sign Up button. 4. After you submit the form (by clicking Sign Up button), Facebook company will send you an email at email address you written in form. Read tha...

How to Create Another Facebook Account

If you already have a Facebook account, but for some reason you need to create another Facebook account. There are following point to note, or way to create another account. 1. If you no longer need earlier account, you can delete that account and create new account using same email address you used with your first account. 2. If you want to create another account without deleting previous account. Facebook do not allow to create multiple accounts with same email address. You must have a new email address, if you don't have one, you should create new email address first. And then create another facebook account with new email address. They have done it to stop spam facebook accounts. Although, one can create new email and then new facebook account, but facebook had put this hurdle so that people avoid creating new accounts. Like one person has only one Social Security Number, same way, facebook also treat email as unique number to counts its 'population' i.e. users. Good lu...

When Servlets are Loaded

If you are developing web applications using Java based technologies, JSP or Servlets. You must be familiar with the loading time of Servlets. First lets see whats mean by loading. If you see the Servlet life cycle. Its as follows: 1. First of all init() method is called (this is called loading) 2. For each request, service() method is called. Which process the request and sends response to user. In case of HttpServlet, the service() method delegates the request processing to doGet(...) or doPost(...), depending on type of request. 3. When you undeploy you web app or stop Tomcat from running, destroy() method is called. You see, init() and destroy() are called only once, after you deploy your application. After serving user request, the servlet instance remains in memory to serve other requests. But the question is, when does the init() method is called first time, or when does the servlet loaded? If you do not do any explicit configuration, the servlet is loaded when first request com...

How Session Work in Web Applications and Why We Need It

Image
Term 'Session' is used in different contexts in computer science e.g. connection, telnet session, session layer, web session, etc. I would discuss the sessions in context of web applications only. There are following fundamental points related to sessions in web applicaitons: 1. What is a session in web application? 2. Why we need a session? 3. How session creation and identification work? 4. Where session data is stored? 5. How to Delete a session? Lets look at each part one-by-one: 1. What is a Session in Web Application? Web developer may need to store small data temporarily at server side, for each user who is interacting with the web application. Such data is stored in a session, so session is a temporary storage at web server. For each user, there is unique session are at server. During request processing of a particular user, the user's session is accessable in all web pages i.e. data stored in session by index.php can be accessed by products.php or a...

How To Improve Object Oriented Programming Skill Beyond Basics

Most software developers join industry after undergrad in CS. The Object Oriented Programming course we study in early BS semester covers only basics of Object Oriented Design. I had good luck to study Design Patterns in MS and other relates stuff by self study. The good thing is, there is nothing difficult of rocket science. If we just have some basic guidelines, we can explore things by our own. Here I would share very brief outline how we can switch our object oriented design skill to next level. Level - I: Object Oriented Programming Concepts Here comes the basics. We should study basic object oriented concepts. These are mostly covered in OOP course of undergrad level. Basic concepts, one must be familiar with at this level includes: Association Composition Aggregation Inheritance Polymorphism Encapsulation Abstraction Generalization Overloading Overriding Level - 2: Object Oriented Design (Patterns) There are some scenarios we frequently encounter during object orien...

My Experience on Cloud with Linode VPS - Its time to say THANKS to Linode

Image
About a year earlier, I developed a reviews portal for products, services and institutions using Java technologies (i.e. FaceRank.PK ), I was not sure how I would host it. Here is how I goes ... I explored different Java based web apps hosting providers. I was almost shocked to see, Java hosting was really very expensive as compare to PHP based hosting. I looked into shared Java hosting, but they didn't provided enough freedom e.g. to restart Tomcat anytime, update JDK, redeploy app. Dedicated hosting were expensive for me, then I explored different Virtual Hosting Providers. From those, I was inspired by users' opinion about Linode.com . I spend a lot of time on web, and I believe, if a lot of users are saying something about a particular provider, there must is something great about it. So I decided to try Linode.com I purchased Linode 768 package. Its almost a year now, guys! Linode is simply awesome. And only 4 times, I need to put support ticket, their response time was be...

How to Scale An Image Maintaining Aspect Ratio Using java-image-scaling API

Image
Below is the static function that I use to scale images in Java using Java Image Scaling 0.8.5 API . When user uploads a file, I pass that file as InputStream to this function, with StandardSize and ThumbSize, the function saves the images at passed fileStorePath with name "newFileName". It also maintains the aspect ratio for thumb and standard image both. import com.mortennobel.imagescaling.ResampleOp; import javax.imageio.ImageIO; // Import other classes here ... public class UtilMethods { public static void saveStandardAndThumbImage(String fileStorePath, String newFileName, InputStream imageInputStream, final int standardSize, final int thumbSize) throws Exception { BufferedImage srcImage = ImageIO.read(imageInputStream); String extension = newFileName.substring(newFileName.indexOf(".")+1, newFileName.length()); int actualHeight = srcImage.getHeight(); int actualWidth = srcImage.getW...

How to Upload Multiple Files using Spring MVC 3.1

Image
Here I share only related parts of the code: 1. Declare Multipart Resolver in spring config file. 2. Define FormBean: public class User implements java.io.Serializable { private String name; private List files; // Must generate getter/setters here } 3. Define the JSP View for Form <%@ taglib prefix="f" uri="http://www.springframework.org/tags/form" %> <f:form action="/users/new" enctype="multipart/form-data" method="POST" modelattribute="user" name="user"> Name:<f:input path="name"> Picture 1 : <f:input path="files" type="file"> Picture 2 : <f:input path="files" type="file"> <input name="Submit" type="submit" /> </f:input></f:input></f:input></f:form> 4. Just get your files in Controller @Controller @RequestMapping ("/users") public class UsersController { @RequestM...

Web Applications Performance Optimization Brainstorming Result

Image
Recently one of my friend asked to share few points about performance optimization that he need to add in a lecture. Here are what major points, I could think of. Feel free to add another point in comments (I will add in post with thanks)! The web applications performance can be optimized on different tiers. I would share some points for each tier. Some are to-do items. Others are little advance and requires protocol level understanding of web. Web Browser Incorporate data compression for things that moves from server to browser (CSS/HTML/JS etc). See  https://developers.google.com/speed/articles/gzip for details. Use AJAX where possible ... to avoid page refreshes, reduce load on server, provide better user experience. Minification of JS and CSS, see various tools here http://www.devcurry.com/2009/11/7-free-tools-to-minify-your-scripts-and.html Let browser to cache resources that you believes would not be updated soon (using HTTP headers) e.g. CSS, images, JS, etc. Merge JS ...

My Reset CSS Stylesheet

I often find me looking into old projects for my very simple reset stylesheet. Not remember from where I get it initially. Here it goes: (sometime I blog things for myself too, so never mind :) html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent } body { line-height: 1 } ol, ul { list-style: none } blockquote, q { quotes: none } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none } :focus { outline: 0 } ins { text-decoration: none } del { text-decoration: line-through } table { border...

Seems the Web Application Architectures are Converging to Message Oriented

It seems the web is converging to messaging based architecture from traditional resource based architecture in which a hyperlink was treated as resource identifier. In recent past, came the RESTful style, that suggested to expose resources on web to let HTTP methods (GET, POST, PUT, DELETE, etc.) play with resources. Now WebSockets are getting into play, that is socket based two way communication between web server and client. The protocol has already been standardized by IETF . The API standardization is almost done by W3C ( see WebSockets API ). With Java perspective, the implementation is already bundled with latest releases of Tomcat and Jetty containers. Java Specification Request ( JSR 356 ) for Java API for WebSockets' Review Ballot closed on March 2012. Spring is highly used framework for different enterprise requirements, on 30 April, Spring Source also  rolled a ticket  to add WebSockets support into Spring Framework. As Java developer, there are a lot of intere...

How to Generate JAX-WS Client Proxy Using Wsimport of JAX-WS 2.2.6 or later

I am using JDK 1.6 on Ubuntu. Implemented web services using JAX-WS 2.2.6 but when tried to generate client proxy code using "wsimport" utility of JDK. It failed, because the "wsimport" utility in JDK 1.6 is older (probably JAX-WS 2.1.6 or an earlier release ships with JDK 1.6) So I used "wsimport" utility that comes with JAX-WS 2.2.6 RI. How? I defined two environmental variables like this, by putting into ~/.bashrc file: JAXWS_HOME=/opt/jaxws-ri2.2.6 JAVA_ENDORSED_DIRS=/opt/endorsedlibs In JAVA_ENDORSED, I pasted jaxws-api.jar and jaxb-api.jar The JAXWS_HOME contains standard files/folders that comes with JAX-WS 2.2.6 Reference Implementation download bundle. Here is how I generated client proxy code: wsclient-project/src:~$>  bash $JAXWS_HOME/bin/wsimport.sh -Xendorsed -s . http://localhost:8181/myproject/webservices/Alpha?wsdl It generates the client proxy code and put into current folder i.e. src.