Skip to main content

Posts

Introduction to Java Programming: Classes, Objects, Methods, and Syntax

When considering a Java program, it consists of objects communicating by invoking each other's methods. Let's delve into the concepts of classes, objects, methods, and instance variables: Object - Objects in Java encapsulate states (e.g., color, name, breed) and behaviors (e.g., wagging, barking, eating). Each object is an instance of a class. Class - A class serves as a blueprint or template defining the behaviors and states that objects of its type support. Methods - Methods represent the behaviors of a class. They contain the logic, manipulate data, and execute actions within a program. Instance Variables - Every object possesses its own set of instance variables. These variables determine the state of an object by holding assigned values. First Java Program: Let's start...

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(); });

HBootstrap Basics: A Simple Guide

Explore Bootstrap basics through a simple HTML setup. Let's create a foundational template: To start, ensure your HTML includes: Proper document structure with <!DOCTYPE html> Basic elements like <html> , <head> , and <body> Viewport meta tag for responsiveness Next, integrate Bootstrap CSS and JavaScript: <link href="css/bootstrap.min.css" rel="stylesheet"> <script src="js/bootstrap.min.js"></script> With these files added, you're ready to leverage Bootstrap's features. Pro Tip: Ensure your css/bootstrap.min.css and js/bootstrap.min.js files are correctly linked to access Bootstrap's styling and interactive components.

HTTP Status Code 501 - Not Implemented

The server either does not recognize 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 support the HTTP method found in the HTTP data stream sent by the client. The method should be one of GET, OPTIONS, HEAD, POST, PUT, DELETE, TRACE, or CONNECT as defined by the HTTP protocol. If the method is valid but not supported by the Web server, upgrading the server might resolve the issue. Fixing the 501 error code Clients should specify a valid request type. If the Web server continues to respond incorrectly, consider upgrading the server. If you're registered with 100pulse, you'll receive alerts via email or SMS when a 501 status code error occurs.

Using Ajax to Query MySQL

Using Ajax to Query MySQL Creating the MySQL Table: 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`) ); Inserting Data into the Table: 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 `ajax_example` VALUES ('Julie', 35, 'f', 90); Client Side HTML File (ajax.html): <!DOCTYPE html> <html> <head> <title>Ajax Example</title> <script> function ajaxFunction() { var ajaxRequest; try { ajaxRequest = new XMLHttpRequest(); } catch (e)...

Using JavaScript Image Map

JavaScript can be used to create client-side image maps, which are defined using the <map> and <area> tags in conjunction with the usemap attribute of the <img /> tag. The <map> element acts as a container for defining clickable hotspots within an image. Each <area> tag specifies a shape and coordinates for the hotspot. Below is an example demonstrating how to use an image map with JavaScript to display different messages when hovering over specific areas of an image: <html> <head> <title>Using JavaScript Image Map</title> <script type="text/javascript"> function showTutorial(name) { document.myform.stage.value = name; } </script> </head> <body> <form name="myform"> <input type="text" name="stage" size="20" /> </form> <img src=...

Page Redirection Examples - Learn How to Redirect Web Pages

Page redirection is essential for directing users from one URL to another. Learn how to implement different types of redirects using JavaScript: Why Use Page Redirection? Migrating to a new domain without losing traffic. Routing users based on browser types or geographical locations. Maintaining SEO when restructuring URLs. Examples of Page Redirection Example 1: Instant Redirection Redirect users immediately: <script type="text/javascript"> window.location = "http://www.newlocation.com"; </script> Example 2: Delayed Redirection with Message Display a message and redirect after a delay: <script type="text/javascript"> function Redirect() { window.location = "http://www.newlocation.com"; } document.write("Redirecting in 10 seconds..."); setTimeout('Redirect()...