Featured
-
How to split a String
Below I have written a code to split a string.
by shahbaz.ahmmod -
Send Push Notification with Custom Data to iPhone device from Java Server Side
This blog will help you to send Push Notifications
by babita.dhami -
Tomcat and Eclipse Integration Error : “Unknown version of Tomcat was specified”
If you are adding Server in Eclipse for Tomcat, an
by chandan.ahluwalia -
Spring MVC and MongoDB
Repository Class Using MongoDB : Spring has th
by sumit.vyas -
How to create DLL file from java?
Hello Guy's This Blog will guide how to create D
by bhagwan.khichar
Tags
Read and Write JSON data in MySQL
Store JSON in MYSQL:- Here below snippet will show you how we can store json data in mysql and read the json data from mysql and convert into a java object. Remember that the field where you can store the JSON data in mysql to set data type of t...
Java.lang.OutOfMemoryError: Java heap space
If you are facing following exception while running your code:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Default size of most of JVM Java Heap Space is around 64MB, it can easily ran out of memory if your appl...
Spring AOP Pointcut, Advisor
Spring AOP :- In Spring we can use AOP module. The AOP is Aspect Oriented Programming that works on cross-cutting concerns. This breaks the program logic into distinct part and these cross-cutting concerns are separated from the business logic of...
Google Guice Dependency Injection(DI)
Google Guice DI:- Google Guice is a Dependency Injection Framework that is same as Spring DI and use to achive IOC and High level of loose coupling to make the relationship between various Business Objects.
Add.java
package add.service;
pu...
Java.lang.OutOfMemoryError: PermGen space
If you are facing following exception while running your code:
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
Default size of most of JVM Perm Space is around 64MB, it can easily ran out of memory if you have too man...
Tomcat Address already in use: JVM_Bind
If you are facing following issue while starting tomcat:
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use: JVM_Bind
at java.net.TwoStacksPlainSocketImpl.socketBind(Native Method)
...
Difference between Include Directive and Include Action tag in JSP
Hello reader's lets know the "Difference between include directive and include action tag in JSP(Java Server Page)".
Include directive and include action tag both are widely-used for including a file to the present JSP page. However you will f...
Spring Security - UserDetailsService vs. AuthenticationProvider
We can use Custome UserDetailsService and custom AuthenticationProvider for user authentication in Spring Security. Here I'm taking example of custom UserDetailsService.
UserDetailsService is a Core interface which loads user-specific data. I...
How to invalidate a spring security session?
To invalidate spring security session you need to follow below steps:
1. Add Logout configuration in your applicationContext-security.xml file
Set logout-success-url attribute to /login.jsp. After logout user will be redirected to this pag...
Spring security 3: database authentication with hibernate
For authenticating the user via spring security we need to make our own custom authentication-provider. We can make our custom UserDetailService easily, here is the sample custom code
MyUserDetailsService.java
package com.users.serv...
Spring Security multiple entry points
It is possible to create more than one entry point in spring security by assigning the different roles here the code script configuration of springsecurity-context.xml.
springsecurity-context.xml
<beans:beans xmlns="http://www.springfra...
How to delete file in Java
Hello readers,
To Delete a File in Java is not a big issue, you don't need to do any rocket science for this.
So if you want to delete the file in java here below is the method.
To delete the file, you just have to issue the File.delete(...
Convert JSON to Java Object
How to convert JSON to a Java object: In many application we use web services and those web services deals with the JSON object, so when those web services need to communicate with our web application we need to convert those JSON objects to Java...
Get Instant Solutions to Java Programming Problems
Hi Geeks,
I am feeling excited to create this video blog about the FindNerd Community Forum and its special features. In this video blog, you will learn how you can handle Java Programming Queries & Language Issues. There are many pro...
Solution for java.lang.UnsupportedClassVersionError bad major version at offset=6
If you are deploying application on Tomcat, JBOSS, or IBM and following error is displayed when you call the application:
SEVERE: Error deploying web application archive MyApplication.war
java.lang.UnsupportedClassVersionError: (com/siperian/...
How to Get Request URL and other details
Following JavaServlet will give you Request URL and other details. You can choose which method suits your coding:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.Htt...
External Dependencies in Maven Project
Dear programmers,
There may many chances when you try to add external dependencies in your Maven project. Let's learn this how we can add our own jars or external jars in a project with an example.
There are many Maven plugins available, A...
Solution for Exception Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
If you face following exception while deploying your application in tomcat:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ApplicationName]]
at org....
How to run java applet on ubuntu
There might be some problem to run java applet in ubuntu while the jdk is already installed in the system. so this problem is occurs when the java plugin is not installed in your browser. The solution of this problem is to installed ORACLE JDK ma...
Spring JAXB Integration
Spring JAXB Integration
JAXB stands for Java Architechture for XML Binding. JAXB is a popular api for the Java object mapping with the xml. With JAXB we can map a Java object to it's corresponding XML document.
It is also called an OXM (Objec...
Spring OXM Castor Example
Spring OXM Castor Example
Spring OXM using Castor : Spring has the feature of xml/object binding. To bind the Object/XML spring use different api. Castor XML mapping is a way to binding the Java object to XML document. It allows to transform ...
Accessing JNDI DataSource with JSTL from JSP
JSTL Sql tags with JNDI datasource : In this article we will show you how to create the JNDI datasource and access it using the JSTL tag library. We will use the tomcat DBCP Connection Pool defined in context.xml, to execute an SQL query and outp...
JSTL Sql <sql:setDataSource> Tag
JSTL Sql setDataSource Tag : Jstl provides the facility to deal with database. JSTL has the separate sql tag library which provides the tags to do database operations.
JSTL provides the <sql:setDataSource> tag which is used to create the ...
Spring File Upload
Spring File Upload
Spring is a framework which provides almost all types of functionality. Spring has feature to stream based file upload. Spring file upload is very easy and maintainable. Spring provides the api to upload file streams. Like j...
How To Install JBoss On Ubuntu
How To Install JBoss On Ubuntu
This article will describe that how to install Jboss application server on Ubuntu. Jboss is a powerful open source java application server developed by RedHat.
To install Jboss we will follow the following ste...
Servlet Filter
Java Servlet Filters :
Servlet filters are the classes which can intercept the request and can modify the response. Filters are not servlets, because filters can not create the response.The purpose of using filters are as follows :
To int...
How to create a custom Function for JSTL
JSTL Custom Function : In this article I am going to teach you how to create custom JSTL function. We had used many JSTL functions which are already in the lib.But if you want to create a custom function for JSTL you need to follow some easy ste...
Java 8- Method and Constructor References
Method Referencing
Method reference is feature related to lambda expressions. Method references are more readable form of Lambda expressions for already written methods. :: operator is used to define method reference. It provides a way to a ...
How to check what Ant version Eclipse is using
In order to check the Ant version in Eclipse, do following:
In Eclipse click on upper Help Menu > About Eclipse -> Installation Details button -> Plug-in Details you will see Apache Ant plugin with version information.
This has bee...
How to resolve permissions issue in Portlet ajax request
In Liferay when we try to do portlet ajax call from view.jsp, we get the issues like permission required or not able to pass the values when trying to pass parameters in ajax call.
To resolve this issue we need to provide permissions. So for ...
Functional Interface - Java 8
The interface with only a single methods is known as functional interface. If an interface marked as @FunctionalInterface it can only contains one abstract method. If we try to declare more than one abstract method inside FunctionalInterface comp...
Install the OpenOffice in Linux and start it's services
To install the OpenOffice follow the below steps:
1- To uninstall Libreoffice(if installed) type the below command from terminal
sudo apt-get remove --purge libreoffice* #if installed
2- To install OpenOffice run the below command fro...
How to iterate Object List in JavaScript
Sometimes we need to send data from Controller to JSp. Here I'm going to explain how we can send and iterate Object List in JSP file. You can do this easily by following the below steps:
1- Define the below dependency in you pom.xml file for...
Default Methods for Interfaces in Java 8
Interfaces always contained only method declaration and there was no way of defining method definition in the interfaces because java did not allow multiple inheritance of classes.
Java only allowed multiple inheritance of interfaces. Since Jav...
Lambda expressions - Java 8
Lambdas?
A lambda is nothing but a anonymous function which accepts zero or more arguments and produces output. Lambda is basically composed with three components- argument section, an arrow and a body.
(argument ...) -> { body } // ...
Install the ODBC in Linux and connect that to your database
To install the ODBC driver and then connect that to your Database follow the below steps:
1- To install ODBC run the below command from terminal
sudo apt-get install unixodbc-dev unixodbc-bin unixodbc
2- To install ODBC driver run the ...
Tomcat and Eclipse Integration Error : Unknown version of Tomcat was specified
If you are adding Server in Eclipse for Tomcat, and you facing below error Unknown version of Tomcat was specified. on Ubuntu then do following:
Steps:
$ cd ~/Downloads
$ wget http://apache-mirror.rbc.ru/pub/apache/tomcat/tomcat-7/v7.0.61/...
Java 8 Higher-order functions
Higher-order means that now it is possible to pass the values as well as functions in the Methods same we can return both values and function from the methods.
Example:
public void show(String name, Function function){ }
public ...
Call Stored Procedure In Hibernate
Call Stored Procedure In Hibernate:
Here is the simple answer of question 'How to call stored procedure in Hibernate?'.A stored procedure is a declarative SQL statements stored inside the database. A stored procedure can be invoked by triggers, ...
SQL Injection attack
Sql Injection
Application security is always a challange for the application developer. As some of anonymous users who try to break your application for his fun. Sometimes loopholes in your application can be more dangerous for you and your ap...
Multitenancy feature in JVM
IBM recently launched the multitenant feature in SDK Java Technology Edition, Version 7 Release 1.
Each program issuing java command from the command prompt/shell or from GUI invokes an instance of the JVM, which contains resources and the ar...
Exception Handling in JSP
Exception Handling in JSP :
Every application has some error handling code. In web application we normally see that error or exceptions occurred and these exceptions are shown by the tomcat using its default error page. In tomcat default error ...
Wiring MongoDB Repository class with Springs controller
Wiring MongoDB Repository Class with SpringMVC:- Spring Data point out the specialties of repository support for MongoDB. To use the repository concept you have to define your repository and attach the required XML element inside Spring Context X...
Repository class using spring-mvc
Repository class using spring-mvc:
As we know that Spring Framework is famous for it's loose coupling architecture. Spring provides a annotation called @Repository, it marks the class, and tells container that this class will be used as a Repo...
Spring MVC and MongoDB
Repository Class Using MongoDB :
Spring has the capability to create loose coupling application's layers. To dealing with database we create a DAO layer. In Spring DAO layer contains the Repository class this class is responsible for all data...
Wiring Repositry class with Springs controller
@Repository annotation:- Annotate all your DAO classes with @Repository. All of the database access logic in the DAO classes. this annotation indicate that this class can done the database related operations like insert,delete,update etc. this i...
Spring AOP Advice
Spring AOP :- In Spring we can use AOP module. The AOP is Aspect Oriented Programming that works on cross-cutting concerns. This breaks the program logic into distinct part and these cross-cutting concerns are separated from the business logic ...
Standard events of ApplicationContext in Spring
Hello Guys
ApplicationContext is manages complete life cycle of the beans in spring application. The ApplicationContext publishes many types of events when loading the beans.
For example:
ContextRefreshedEvent : It is published when the Applic...
Calling Stored Procedure from Java Code
Let say you have requirement to call stored procedure from your Java code. You can use following sample code for your reference. Change the connection source as per your requirement and call the method.
package com.app.util;
import java.sql...
Simple Encryption Decryption using AES in Java
Following is Simple Encryption and Decryption using AES in Java. Data Encryption Standard (DES) is prone to brute-force attacks. It is a old way of encrypting data. It is replaced by Advanced Encryption Standard (AES).
If you have Java 8 you ...