Skip to main content

Posts

Basic Hello World Program in Java

When we consider a Java program it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and instance variables mean. Object -  Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class. Class -  A class can be defined as a template/ blue print that describes the behaviors/states that object of its type support. Methods -  A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. Instance Variables -  Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables. First Java Program: Let us look at a simple code that would print the words  Hello World . public class MyFi

How to delete first preceding element

Here is the html from which I want to remove the div element 'div' by clicking the link. <div> <a href="javascript:void(0)" class="link">My link</a> </div> To access   the preceding element I will use the .parents() method of jQuery and then call  the method .remove() to remove the 'div' element. Here is the code... $('a.link').click(function() { $(this).parents('div:first').remove(); });

HTML template using bootstrap

With a brief intro into the contents out of the way, we can focus on putting Bootstrap to use. To do that, we'll utilize a basic HTML template that includes everything we mentioned in the File structure . Now, here's a look at a  typical HTML file : <!DOCTYPE html> <html> <head> <title> Bootstrap 101 Template </title> <meta name = "viewport" content = "width=device-width, initial-scale=1.0" > </head> <body> <h1> Hello, world! </h1> <script src = "http://code.jquery.com/jquery.js" ></script> </body> </html> To make this  a Bootstrapped template , just include the appropriate CSS and JS files: <!DOCTYPE html> <html> <head> <title> Bootstrap 101 Template </title> <meta name = "viewport" content = "width=device-width, initial-scale=1.0" > <!--

HTTP Status Code 501 - Not Implemented

501 Error Code Explained The server either does not recognise the request method, or it lacks the ability to fulfill the request. Why it occurs The error occurs when the Web server does not understand or does not support the HTTP method it finds in the HTTP data stream sent to it by the client. The method in the request HTTP data stream should be one of the following GET, OPTIONS, HEAD, POST, PUT, DELETE, TRACE and CONNECT as defined by the HTTP protocol Or the method may be valid but not actually supported by the Web server. Fixing 501 error code The client should specify a valid request type. Even after that if the Web server is responding incorrectly, then the web server simply needs to be upgraded to fix the issue. If you are registered with 100pulse, your site will be monitored and you will be intimated by an email or a short message service when 501 status code error occurs.

Ajax Database

To clearly illustrate how easy it is to access information from a database using Ajax, we are going to build MySQL queries on the fly and display the results on "ajax.html". But before we proceed, lets do ground work. Create a table using the following command. NOTE: We are asuing you have sufficient privilege to perform following MySQL operations CREATE TABLE `ajax_example` ( `name` varchar(50) NOT NULL, `age` int(11) NOT NULL, `sex` varchar(1) NOT NULL, `wpm` int(11) NOT NULL, PRIMARY KEY (`name`) ) Now dump the following data into this table using the following SQL statements INSERT INTO `ajax_example` VALUES ('Jerry', 120, 'm', 20); INSERT INTO `ajax_example` VALUES ('Regis', 75, 'm', 44); INSERT INTO `ajax_example` VALUES ('Frank', 45, 'm', 87); INSERT INTO `ajax_example` VALUES ('Jill', 22, 'f', 72); INSERT INTO `ajax_example` VALUES ('Tracy', 27, 'f', 0); INSERT INTO

Image Map in javascript

You can use JavaScript to create client side image map. Client side image maps are enabled by the usemap attribute for the <img /> tag and defined by special <map> and <area> extension tags. The image that is going to form the map is inserted into the page using the <img /> element as normal, except it carries an extra attribute called usemap. The value of the usemap attribute is the value of the name attribute on the <map> element, which you are about to meet, preceded by a pound or hash sign. The <map> element actually creates the map for the image and usually follows directly after the <img /> element. It acts as a container for the <area /> elements that actually define the clickable hotspots. The <map> element carries only one attribute, the name attribute, which is the name that identifies the map. This is how the <img /> element knows which <map> element to use. The <area> element specifie

Redirect a page in javascript

What is page redirection ? When you click a URL to reach to a page X but internally you are directed to another page Y that simply happens because of page re-direction. This concept is different from JavaScript Page Refresh. There could be various reasons why you would like to redirect from original page. I'm listing down few of the reasons: You did not like the name of your domain and you are moving to a new one. Same time you want to direct your all visitors to new site. In such case you can maintain your old domain but put a single page with a page re-direction so that your all old domain visitors can come to your new domain. You have build-up various pages based on browser versions or their names or may be based on different countries, then instead of using your server side page redirection you can use client side page redirection to land your users on appropriate page. The Search Engines may have already indexed your pages. But while moving to another domai