Java Core

SSL handshake alert: unrecognized_name Exception


This tutorial explains how to handle SSL handshake alert: unrecognized_name exception while calling an URL over SSL/https . When I tried to connect a web-server over SSL, I was getting the below error continuously. This happened with JDK1.7 and above. Below is the sample Java programme which I was running. Issue : private static String makeSSLCall(final String URL) throws Exception ... Read More »

URL shortening using google API


URL shortening using Google API Sometimes we need to share a long URL or we need to tweet them. But because of the length of the URL we are not able to do so. Google provides a service using which we can convert our long URL and squeezes them to fewer character URL. This service of Google is also known ... Read More »

GSON encoding the string like \u003d


This tutorial explains how to handle the encoding issue with using GSON. Below is a sample programme in which GSON was converting string, with some special character, into some encoded character. Map<String, String> dataMap = new HashMap<String, String>(); dataMap.put("userid", "sdswSSEdafsdy2y4=="); Gson gson = new Gson(); String json = gson.toJson(dataMap); System.out.println("Json result - "+json); But when we printed the GSON string ... Read More »

How to encode decode String in Java base64 Encoding


Base64 Encoding Algorithm Base64 encodes String using an algorithm which uses 64 printable characters to replace each character in original string in an algorithmic sequence so that it can be decoded later. Base64 encoding prevents misuse of data by encoding it into ASCII format. Base64 is real simple and easy to use for simple encoding needs. There are more advanced ... Read More »

How to read and parse CSV file


This tutorial shows how to read, parse and print out the values from a CSV file. Say we have a CSV file user-profile.csv where the user name, roll number, age, course name is stored, seperated by comma. Sample file data “Aman”,”A1234″,23,”B.Tech” “Rahul”,”A1235″,21,”B.Tech” “Ravi”,”A1236″,24,”B.Tech” “Maxwell”,”A1237″,23,”B.Tech” “Patrick”,”A1238″,26,”B.Tech” “John”,”A1239″,20,”B.Tech” Extracts the Roll Number and Course from above CVS file, and print it out. ... Read More »

What is Memory Leak & How can we avoid Memory Leak


Memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs which by definition never terminate. Usually developers talk about memory leaks but when you ask them what that means many have no idea. To prevent these situations, Lets discuss about memory lean in detail. Memory that is ... Read More »

How to install visualvm in Ubuntu


VisualVM is a visual tool, integrating several command line JDK tools and lightweight profiling capabilities. Designed for both production and development, it further enhances the capability of monitoring and performance analysis for the Java platform. VisualVM is designed for- Java Developer: Monitor, profile, take thread dumps, browse heap dumps. System Administrator: Monitor and control Java applications across the entire network. ... Read More »

Anti cross-site scripting (XSS) filter for Java web applications


XSS (cross-site scripting)is the most prevalent web application security flaw. XSS flaws occur when an application includes user supplied data in a page sent to the browser without properly validating or escaping that content. Detection of most XSS flaws is fairly easy via testing or code analysis. How Do I Prevent ‘Cross-Site Scripting (XSS)’? HTML escaping Escaping of Input Escaping ... Read More »

Difference between JDK, JRE and JVM


If we are a Java developer, it is very often that we think about understanding the JRE,JVM and JDK. It would be quite easy for us to visualize things in logical manner. Let’s see the basic differences between the JDK, JRE and JVM. JDK (Java Development Kit) Java Developer Kit contains tools needed to develop the Java programs, and JRE ... Read More »