How to configure sessioncookie at Tomcat server level OR at Application level (web.xml)

How to configure session cookie at Tomcat server level or at Application level (web.xml) In this post we will see how to configure session cookie at Tomcat server level or at application level using web.xml You can use either way to set a cookie. Tomcat server Go to -> conf directory -> open context.xml -> add below lines:- <Context sessionCookieName="<yourCookieName>" ... Read More »

Javascript Browser back button handling

Javascript Browser back button handling In Javascript getting handle of browser back button event is complex. There are many plugIns available to satisfy this complex need. However, I cam across a solution which to some extent can resolve this issue. if (window.history && window.history.pushState) { if(location.hash.split("#")[1]!='search'){ window.history.pushState('forward', null, '#search'); } } This piece of code will first do a forward ... Read More »

URL shortening using google API

Java

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

Java

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 »

Integration of Android Studio and Git

android

This tutorial explains how to use Git Version Control with Android Studio. Git is a distributed version control system. Git is a best choice among all the version control software like CVS, SVN etc. Android studio comes with Git client. All we need to do is just enable and start using it. As a prerequisite, we need to have Git ... Read More »

How to encode decode String in Java base64 Encoding

Java

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

JavaIO

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 »

How to install HTTP Apache, MySql, PHP, PhpMyAdmin from source-Part 2

apache

Install HTTP Apache from source 1. Download source mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz from http://dev.mysql.com/downloads/mysql/ 2. Copy the downloaded file to folder where you want to install MySql, for my case I copied in /opt/soft-install/ directory 3. Extract the file at this location, command to extract cp -av mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz /opt/soft-install/ tar -zxvf mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.24-linux-glibc2.5-x86_64 mysql-5.6 4. Go to the bin directory of the ... Read More »