How to Get localhost IP Address in Java

Using the java.net.InetAddress, We can Get the localhost IP Address in Java. To get the localhost IP, We can Use the Code like import java.net.InetAddress; import java.net.UnknownHostException; public class IPAddress { public static void main(String[] args) { try { InetAddress ip = InetAddress.getLocalHost(); System.out.println(“IP is : ” + ip.getHostAddress()); } catch (UnknownHostException ex) { ex.printStackTrace(); … Read more

UnZIp Files using java.util.zip Package

Java provides the java.util.zip package to compress and decompress the files, to UnZip the zip file We are using ZipInputStream Class for input stream filter for reading files in the ZIP file format, ZipEntry Class to represent the Zip file entry and ZipOutputStream Class for output stream filter for writing files in the ZIP file … Read more

Restore MySql DB on Windows using Java

MYSQl is the world’s second most widely used open-source relational database management system. MYSQL RDBMS provides the mysql shell to restore the database, We can invoke the mysql command from command Prompt to restore the database, mysql shell can also be invoked from java using the java.lang.Runtime class. In the example we are going to … Read more

Introduction to Struts 2

Apache Struts is a free, open-source, MVC framework for creating elegant, modern Java web applications. It favors convention over configuration, is extensible using a plugin architecture, and ships with plugins to support REST, AJAX and JSON. Struts 2 is a pull-MVC framework. i.e. the data that is to be displayed to user has to be … Read more

Servlet: an Overview

A servlet is a Java program that runs in a Web server. The servlet takes an HTTP request from a browser, generates dynamic content like querying a database, and provides an HTTP response back to the browser. Alternatively, the servlet can be accessed directly from another application component or send its output to another component. … Read more

Java: an Overview

JAVA is a programming language and environment that was designed to solve a number of problems in modern programming practice. It is a general-purpose computer programming language that is concurrent, class-based, object-oriented and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers “write once, run anywhere” (WORA) … Read more

Zip Files in Java Using java.util.zip Package

Java provides the ‘java.util.zip’ package to compress and decompress the data. To get started, we will need to import the necessary classes from the java.util.zip package. These classes allow us to work with zip files and compress data. In the below example we are using ZipOutputStream and  ZipEntry Class. Both are essential classes in Java’s … Read more

Check whether an Element Exists using JQuery

In JavaScript to check whether an element exist or not we can use something like this if(document.getElementById( ‘Elementid’ )) But in case of jQuery to check an element exist or not the code can be written like this if ( $( ‘#elementId’ ).length >0 ) We can also leave the >0 and the code will … Read more