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

How to load properties file and fetch values by using annotation in Spring

Properties file: It is basically used to store data that is constant and can be used anywhere in the program. Example: You can store the database credentials and connection parameters in the file and fetch it when required. How to use: ...

How to get file metadata in java

Hello Guys Here, I am writing about extract the metadata of the file in java technology in which you can extract file creation date, file access date, modification date, size etc. Java provide inbuild BasicFileAttributes class in the JDK....

Diffrence between Method Declaration and Method definition

Hii ,friend's Today I will expain you about the diffrence between Method Declaration and method definition. In Method Declartion you can declare somthing like [public void my function();] here myfunction is the name of method. And In Method...

How Jersey return a JSONObject?

If we try to return a JsonOject in jersey, like this @Path("/formSubmit") @POST @Produces("application/json") public JSONObject formSubmit() { JSONObject json1 =new JSONObject(); return json1; } it may give an error (org....

How to validate a form on submit?

Whenever we create a form, we always have a requirement to put validation for empty fields on some input fields on form submit. For this we use onSubmit attribute of the form, inside which we can define a function that will have validations. E...

How to check if an array contains a specific string in jQuery?

Sometimes we need to check if a particular string exists in an array or not, we can do this by using inArray() method of jQuery very easily. Example <!doctype html> <html lang="en"> <head> <meta charset="utf-8"&g...

What is the difference between == and equals in Java?

In Java, the "==" operator is used to compare references. When we use the == operator in Java it compares 2 objects, it checks whether the two objects refer to the same place in memory or not. Example: String str1 = new String("abc"); S...

JSON with JAVA

A JSONObject is an unordered amassment of name/value pairs. Its external form is a string wrapped in curly braces with colons between the designations and values, and commas between the values and designations. A JSONObject constructor can be ...

Class Not Found Exception org.springframework.web.context.ContextLoaderListener

Class Not Found Exception org.springframework.web.context.ContextLoaderListener Sometimes, when we build a project using maven, we find the error " Class Not Found Exception org.springframework.web.context.ContextLoaderListener " even after...

REST using jersey in springs.

RESTful web services A RESTful web accommodations are predicated on HTTP methods and the concept of REST. A RESTFul web service defines the base URI for the accommodations, the fortified MIME-types and operations like POST, GET, etc. JAX-RS...

Spring Junit Test

Hello Guys! Testing is a very most important part of any project. Without good testing, a good product is uncertain. We have different frameworks available for testing the product functionality. We have a good framework JUnit available in Java....

Remove duplicate items from ArrayList.

I am removing duplication from arraylist. To do this, first add all the items of arraylist to a HashSet. HashSet takes only unique items. Finally, take HashSet items to the arraylist. List arrayList = new ArrayList<>(); arrayList.a...

What is Overriding in Java?

When a sub class inherits the properties of super class , then we can override the method of super class. This will acquire the properties of super class but can define its own behaviour. In general way, we can say the overriding means to ...

CSRF with Spring and AngularJS

In this blog, We will see how to configure CSRF protection and how to make AngularJS allowed to send information with a CSRF token to the server. In AngularJS, $http service reads a token from a cookie which is named by default XSRF-TOKEN and se...

CSRF configuration in Spring

In this blog, I am going to explain how to implement Cross-Site Request Forgery protection in Spring. No need to worry to enable CSRF in Spring. Spring Security comes with CSRF enabled. And if required we can disable it as well. Although disablin...

Multiple file upload using fineuploader in springs.

For multiple file upload, we are using fineuploader plugin with spring mvc. There is need to include the scripts of fineuploader plugin which allow to select the multiple files at a time. And then getting those files as multipart file using @Requ...

How to enable Cross-Origin Requests for a RESTful web service.

The RESTful web service need to include CORS access control headers in its response, there we have to add a @CrossOrigin annotation to the handler method. It enables cross-origin requests only for the particular method. It allows all the HTTP me...

Use of filters in Servlet

Servlet Filter: Servlet Filter is used to filter the unnecessary requests that is received at the servlet end. It is used to perform tasks such as conversion, logging, compression, encryption and decryption, input validation etc. It is call...

How to print a List is Java?

There are different ways to print a List, below are some example to print a list using: 1. For loop 2. While loop, and 3. Iterator import java.util.Arrays; import java.util.Iterator; import java.util.List; public class printmyList { ...

How to print a java array using Arrays.toString

An Array is a collection of data of similar data type. We can use Arrays.toString(array_name) to print a java array. Arrays.toString() return a String for a given set of elements specified in brackets([]) and, the elements are separated wi...

Check WSDL for WS-I compliance using the SoapUI

If you are developing web-service, your web-service should be at-least WS-I Compliance to work correctly on other system like SAP, Dynamics etc. You can Check your WSDL for WS-I compliance using the SoapUI WS-I compliance test. You need to do ...

Increase Timeout in SoapUI

Default socket timeout in SoapUI is set to 60000 milliseconds i.e. 1 minute. You can change the value if you are facing "Connection timed out:" error. This error could be due to heavy processing in web service, or resources being busy. Soc...

Error in SoapFault from Webservice

If requirement is to show the error in SoapFault from Webservice, you can use below code. Just pass the faultMessage to the method and it will return the SoapFault: /** * Soap Fault return in case of error * @ chandan Dec 17, ...

How to upload files to Server using JSP Servlet

Step 1: Configure web.xml, add <multipart-config> <multipart-config> <max-file-size>1234</max-file-size> <max-request-size>5678</max-request-size> </multipart-config> ...

Custom Exceptions in Java

An exception is any problem that occurs during the execution of a program and disrupts the normal flow of the programs instructions.In basic terms, when a condition occurs, in which it is not sure how to proceed in an ordinary way it creates an e...

Use of intern() of string in Java

String.intern() has a great importance in java. We can use String.intern() to deal with String duplication problem in Java. A string is said to be duplicate if it contains the same content as another string but has a different memory location e.g...

User Authentication using LDAP

If your application has requirement to authenticate user using LDAP you can use following code for same: LDAP: is Lightweight Directory Access Protocol. LDAP server will be having users information, and requirement could be to only authenticat...

SEVERE: Exception unloading sessions to persistent storage

While making changes in jsp pages in eclipse IDE, i was continously getiing error: java.io.FileNotFoundException:/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/_/SESSIONS.ser SEVERE: Exception unloading sessions ...

Deploy project on tomcat start without project name

When we deploy project in tomcat, by default its run as http://<ip>:8080/warname/index.jsp But when we use domain name and wants that on running tomcat automatically the projects main page is opened, we simply need to add following...

How to use Ext.define in ExtJS 4

Ext.Define function is a part of EXTJs. ExtJS is a advance javascript framework, It used to create java class and their method by using javascript. I write the Ext.define method below : Ext.define ( String className, Object data, Func...

Servlet request processing by Web Server and Servlet container

1. Web Server A web server is basically used to give the response to the request specified by the browser (user). It basically uses HTTP protocol for the transmission of data. eg. A user can request for some page by entering the web addres...

Applet in java

APPLET Applet are the client side web based program run on web browser. Applet implements the functionality of the clients.Dynamic and interactive programs runs inside a web page with a displayed Java capable browser.We don't have constructor...

Extract metadata using ImageIO in java

Hello guys We are creating a file which have some information about file i.e create date, modify date, tags and description etc. called metadata of the file. Now, We are extract the Imagedata using javax.imageIO package requires Imag...

Expression Tag in JSP

JSP Expression Tag : In JSP the Expression tag is used to print in the output stream.So whenever you have some data to print into the screen or can say browser you can use the JSP Expression Tag. The java code '<% out.println(msg); %>' c...

Create User Defined Session in Java

User Defined Session ID: As we know that the session is used to check the user's state. Almost every web application handles the user session. Their are number of ways to maintain the session like using url rewriting, hidden fields, cookies, web ...

How to add JTable in JPanel

Hello Guys I writing blog to add JTable in Jpanel. JTable is an component of the swing package in java technology and also it's a class, so we need to create instance and using add() method add the JTable in JPanel. Here, add() method used fo...

What is the difference between an int and an Integer in Java

Well, in Java technology an int is a primitive type while an Integer is an Object or wrapper class. Meaning, if you made a new Integer: Integer integerObj = new Integer(6); You could call some method on integerObj: String str = integer...

Main method in java

Hello guys Here, I am simplifying the java main method, In which beginners have many confusions about public, static, void and String array. First of all see below simple java example : package bhagwan; public class Findnerd { ...

How to decompile .class file to .java file

Hello Guys Most of the time we are thinking .class has bytecode and it's not human readable but it's right thinking so we have another technologies which can decompile .class file to human readable means .java file. Now, I illustrate the ja...

How to compare strings in Java

There are two ways of comparison in Java. In you just want to match value of the string Object.equals() will be used. It simply compares the string values. While if you use == to compare, it will check the object reference. So new S...

Prevent site from showing up in search results on Google, Bing and other search engines

Sometimes we need to prevent our testing.dev site from showing up in search results on Google, Bing and other search engines until we are ready to launch. We can do this by addting "X-Robots-Tag" paramet to header of the response. Create filte...

File uploading using Spring MVC

Spring framework based on java technology and it's comes with MultipartResolver to handle upload files in web based application. The MultipartResolver has CommonsMultipartResolver which use the Apache commons upload library to handle the uploa...

How to open another page with button click in jQuery?

Sometimes we need to open another page on button click. We can do this in tow ways either by using "window.location" or "window.open()". Example: In the below example I have put conditions on "blur" event for checking whether the input fiel...

How to implement select event of Autocomplete feature in jsp?

Sometimes we need do functionality when we select any item from the suggestions that display by autocomplte feature. Example: In the below example I'm using autocomplete() function to get suggestions with the provided keyword. As below by impl...

How to create a web service

SOAP:Simple Object Access Protocol defines the request and response message format in a web service. It is XML-based communication format and encoding format for inter-application communication. SOAP is built to use for cross-platform, cross-lang...

How to implement autocomplete feature with AJAX in jsp?

Sometimes wee need to call an API or action to get matching list with the provide keyword in Search box, for this we usually implemente autocomplete feature to input field for searching purpose by doing AJAX call. Example: In the below example...

HttpSessionListener Interface in Servlet

HttpSessionListener in Servlet : We all know that user state is maintained in almost all the web applications like you have seen in shopping websites or banking websites etc. In java we mostly use application server's session handler. But what if...

How to check/uncheck checkbox with jQuery?

Sometimes we need to check/unchecked checkbox based on some condition. We can do this easily by using "checked" attribute of a button. Example: <input type="checkbox" id="addressCheckBox" class="form-control"> <label>I confir...

How to apply autocomplete feature to textbox with jQuery?

Sometimes we need to implement autocomplete feature to input field for searching purpose. We can do this by using "autocomplete()" with jQuery. Example: In the below example I have created an array of country names and passed that as source to...

Configuration JNDI DataSource for MySQL

JNDI DataSource Configuration This blog is written with the aim to show JNDI DataSource configuration for a web container like tomcat. JNDI stands for Java Naming and Directory Interface, a directory service provided for java-based client a...
1 5 13
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: