Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

if-else in jstl

In JSTL, the functionality if-else is provided by choose-when-otherwise statement . <c:choose> tag is an enclosing tag for <c:when> and <c:otherwise>. And it is also known as mutual exclusion as only a block of code withi...

Send data through ajax call and receive Json response from controller in Springs

Here is the sample code implementing ajax call to send the data of a form to the controller and receiving json response from controller. Student.java Create a java bean class and generate setter and getter. public class Student { ...

Spring Security 4: Auto login with annotation

Spring security gives us the feature to auto login into the system just after creating an account. Other way is to register then go to login page, and then login to the system. When we login login mechanism spring automatically creates the sess...

Remove some particular character from a String

Sometime, we need to remove or replace some particular character from a String. Below is the method by which we can accomplish this. I am using replaceAll() method of the String. replaceAll() have two parameter as an arguments. First one is t...

Sort alphanumeric string with awareness of number using Java comparator

The java by default sorting is based on either number or string. If we try to sort a alphaneumeric it will be treated as an string so the sorting will come something like: 1abc 11abc 2abc instead of 1abc 2abc 11abc So in such cases w...

To create database and insert data in SQLite, in android

If you are looking for the code in android to create database and insert data in SQLite then follow the steps mentioned below:- 1) Create a layout in which the data will be filled that will be inserted into database. activity_signup_form....

How to reset ArrayList in Java - Clear vs RemoveAll

To reset ArrayList we have two options, one is to use clear() method and another is to use removeAll(). We dont need to worry if size of the ArrayList is small i.e. 10 to 100. But if ArrayList size becomes huge the difference in the performan...

Convert Map to List

Map and List are the two commonly used data structures Here I am writing way to convert Map to List. Basically Map holds two things are key and value on the other hand list holds only values. Both Map and List allow duplicate data. Below i...

How to execute additional code just after opening a new page using Angular JS

In the cases when you execute any server and your attempts to load a new page view and then your codes in directive gets loaded before your services are updated so you can using $rootScope. This is an example of above case View <serv...

Threads

Threads Threads are used to get the multiple activities in a single process. They are light weight programs. They share memory and files and process state. They have their own local variable and stack and program counter. Every jav...

Static Keyword

Static Keyword Static keyword can be applied on 1.Method 2.Variable 3.Class nested within another Class 4.Initialization Block Static keyword can not be applied to 1.Class (Not Nested) 2.Constructor 3.Interface 4.Met...

Convert String to Date in Java

Its very easy in java to convert String to Date. Java provides SimpleDateFormat to handle Date related functionality. Here we call parse() method of SimpleDateFormat. Example import java.text.SimpleDateFormat; import java.util.Date;...

Phone number Regex Java

Regex for mobile number validation with prefix of '+' ^[+][0-9]{12,13}$ Regex for mobile number validation with optional '+' ^[+]?[0-9]{10,13}$ Use in Code:- Pattern.matches("^[+][0-9]{12,13}$",mobilenumber); Ha...

Constructor in Java

Java Class Constructor It is special kind of function, but doesn't have a return type. It has the same name as class name. Constructor is used to initialized the variable of class. we can't call the constructor with the help of object. If...

Get Current Date in Java

Hello, We need current date in many situations. Here I am writing different ways to get current date in java. 1. Get current date using java.util.Date. Date currentDate = Date(); System.out.println(Current date : +currentDate); O/P: Curr...

How to put coma between hundreds and thousands of any given number

Hello reader's! On a given number format if you want it to be customize like a figure with separated by (,) like 128,347,556. By using a function and in the function we will Preg Match the string with every hundreds and thousands You can use...

Covariant Return Type

When return type of the method of super class is different than the return type of method of subclass and it is also a method overriding then it is known as covariant return type. And here the return type is non primitive. I am writing the si...

Access Denied in spring security 4 even after successful authentication

In spring security after successfull authentication I was getting the Access denied error to go to pages which had the authentication. What I did was. @Override protected void configure(HttpSecurity http) throws Exception { ht...

How to add multiple properties file in spring configuration

Here we have configured the spring mvc configuration. In @ComponentScan we can give the path where we have our components(like controller, model, dao etc). For adding the single properties file we use: @PropertySource("classpath:application.p...

How to disable csrf spring security 4

In spring security bydefault the csrf protect in on. As a result it asks for token during login and other requests. Although its not a good practise to disable the protection but we can do it. As we can see in the code below, http.csrf().disable...

How to authenticate MD5 password encyption in spring security 4

Whenever we deal with password in an application, we go for some encryption. In spring the password it authenticated within the configuration. Here is the sample code where we have already saved the password in encrypted form and now during lo...

Encapsulation

Encapsulation is a concept of wrapping up of data into a single unit and hiding implementation details from the user. If we use the private method then they can not be accessed in the other class. If we put a getter setter method to update ...

Final Keyword

Final is keyword that can be used before a class or method or a variable. Final Class They can not be subclassed and the method in it are by default final. public final class MyFinalClass {...} public class ThisIsWrong extends MyFinal...

Access Modifiers

Access modifiers in java are used to control the access of other classes to access the class or method. There are different type of access modifiers used 1.Public-It is the default access modifier it means that your class or method is visib...

Exception Hnadling

Exception handling in java is a way to catch error or exception Exception is an event that can occur during the execution of the program. We use try catch and final to catch error. When an error occur in a method it creates an object of ...

Interface vs Abstract Class

Interface Interface can extend many interface. Interface can extend from a interface only. Interface have only abstract method by default. Interface can have public method only it it. Abstract Abstract can attend only on class at a time. ...

Abstract Class

Abstract class are simply the base class. They can not be instantiated but can be subclassed and have protected, private method unlike the interface. Abstract classes can be declared by simply using the keyword abstract. abstract class Graphi...

Interface

Interface is the way to get the multiple inheritance. This means that a class can inherit two or more class. As java, we can not extend more than one class but we can extend more than one interface. So Interface is used to have inheritance Bu...

Inheritance

Inheritance in java is concept by which one class can have the method of the other class. The class that is being inherited is called Base or Parent class and the one which derive is called the Derive or child class. Inheritance can be of the t...

Method Overriding

Method Overriding is a type of polymorphism. It is dynamic type of polymorphism. In this we have the method with the similar name in both parent class and child class. But the child class override the method of the parent class when we create ...

Method Overloading

Method Overloading is a type of polymorphism. Using this we can have two different method having the same name in a single class. Method have the same name but different argument through which they are recognize. Argument have 1.Different num...

HttpSessionAttributeListeners in Servlet

In Servlet we can also track the events using the Listeners, In below code script we have to track the events using the listeners. we have easily maintained the HttpSession events with the HttpSessionAttributeListener while we add, remove or repl...

Stack in java

In stack, we save elements in last-in, first-out manner. Stack extends the Vector class and have only one constructor that is default. By this default constructor, we can create an empty stack. Below is the example. public class Exampl...

How to know the call state in Android

Android provide us the facility to know the call state. Android gives this feature by providing Telephonymanager class. We need to implement PhoneStateListener interface that has one method onCallStateChanged(). Below is the example. publ...

SortedSet in Java

I am writing a way to implement SortedSet in java. SortedSet have the properties of Set interface plus feature of sorting in ascending order. It is by default provides elements in ascending order. It is very useful in such situation when we do...

LinkedList implementation in Java

Hi friends, Here I am writing a way to implement basic LinkedList. First of all LinkedList has the properties of List interface and AbstractSequentialList class because it implements List interface and extends AbstractSequentialList. ...

Implement Producer Consumer Problem Using Threading in Java

ProducerConsumer problem is also known as the bounded-buffer problem.It is multi-process synchronization problem.There are two processes one is producer and another is consumer that can share a common and fixed-size buffer. The producer insert th...

Adding and Deleting items in dropdown using javascript.

Hi Readers! In this blog we will learn How we can Add and Delete items in dropdown in JavaScript. .In the bellow example we are going to add items in dropdown and delete selected item from the dropdown list on specific button click . <...

Implement Generic Method in Java

Generic Methods:- The Below code will helps you to implement Generic Method using the Generic Programming in Java. The generic methods enable us to specify, with a single method declaration and use with different data types. we can write a single...

How to Construct your own ArrayList Using Generics

Here the Below Example will show you how you can construct your own Collection(ArrayList) in Java. The below example will show you that our Class Generics will behave like the ArrayList. I have use the Generic Programming to Implement the concept...

Static in Java

One of the most important topic that we encounter in java. We can use static with class name, methods name, variables name and block. Static keyword mainly used for memory management. Static variable Static variable takes memory o...

Spring MVC @RequestParam Usses

For Get request we need to pass parameters as request param along with the url to get the data. In Spring MVC framework, we can customize the URL in order to get data. To read the parameters passed with the URl we use @RequestParam in Spring fram...

Spring MVC @RequestParam vs @PathVariable

@PathVariable: Sometimes we need to pass parameters along with the url to get the data. In Spring MVC framework, we can customize the URL in order to get data. For this purpose @PathVariable annotation is used in Spring framework. @PathVariabl...

How to match a word in Java?

Sometimes we need to match some words in a particular String. We can do this easily by matches() method of String class. Example: package com.demo; public class TestApps { /* *@param args */ public static void mai...

How to replace whole word with Word Boundaries in Java?

Sometimes we need to replace whole word with the word boundaries in a string. For this we use "\b" regular expression token which is called a word boundary. It usually matches at the start or the end of a word. Example: You just need to place ...

How to replace Case-Insensitive chars in a String in Java?

Sometimes we need to replace some characters with some other set of characters. To replace a Case-Insensitive chars from string you can use the below example: package com.demo; public class TestApps { /* *@param args */ ...

Use of JPA(Java Persistence API) to implement ORM

JPA:- Java Persistence API is a collection of classes and methods to persist or store data into the database Using the JAVA API. The Below code will show you how you can work with JPA. First we make the POJO. Employee.java package...

HashSet in Java

Here I am writing a way to implement Hashset. HashSet creates hashtable to store the data. As it implements Set interface so it doesnt contains duplicate elements. It also extends AbstractSet class. We can implement HashSet by using different...

Enumeration Interface in Java

Enumeration is used to retrieve or traverse all the elements of particular collection of objects. Its not considered for collections but we can use it for legacy like Vectors. To use it we need to import - Java.util.Enumeration Below is the ...

Iterator in Java

In collection, there would be many situations where we need to retrieve the collection elements. Example, we need to show each element. For these situations Iterator is the best solution. How it implements :- First iterator comes to start p...
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: