You are here: Home // Programming
Logging with log4j
This article is contributed by Debkumar Basu. He has done an excellent work with Log4J… read it to learn more.
===================================
I was just looking for some cool examples of log4j.properties for a custom application. After some googling and couple of hours of “trial and error”, I came up with this following Log4j.xml.
Have a look, may seem handy to some of you…
The following...
Step by step guide to create Singleton design pattern with Java
Singleton design pattern is a kind of design pattern which helps a java developer to apply restriction to a class to have one and only one instance. This way the developer can ensure as well as can control how an object is instantiated and can prevent others from creating or copying multiple instances of the class.
Purpose: The main purpose is that if we have to use a resource then we can create a...
Creating a struts project using Eclipse Ganymede
Here is a short article that may help you while creating a struts project in Eclipse’s latest 3.30 i.e Ganymede. Please follow the following steps :
1 . Create a Dynamic Web Project
#gallery-1 {
margin: auto;
}
#gallery-1 .gallery-item {
float: left;
margin-top: 10px;
text-align: center;
width: 33%; }
#gallery-1 img {
border: 2px solid #cfcfcf;
}
#gallery-1...
Validating correct email id format using PHP and regular expression
Sometimes we need to validate if user has entered the correct email id format or not in contact form or signup form or guest book. In PHP we can use regular expression to validate if the user entered emailid is in correct format or not. Below code sample of a method just does the same. If you have any queries please post at PHP category in the forum and I’ll try to answer.
This function...
How to open Modal window in Javascript
Sometimes we need to show Modal window in our web application. This window basically opens a popup window which does not allow the user to click any link in the background. User will be able to click on the background when he/she closes the window. The code snippet is given below:
<html>
<body>
<script anguage=“JavaScript”> function openWindow()
{
var myArguments...
Reading user input in java
Sometimes in our stand alone java program we need to read user input data. Below code snippet will show you how to read user input in a Java application.
package com.tctalk.myapp.java.src;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* ReaduserInput.java – [This code reads the user input data from command prompt]
*...
creating non duplicate array from duplicate array in Java
This example helps you to generate a fresh and non duplicate array of elements from an array having duplicate elements. However there is a problem in this code. The nonduplicate array tends to have 0 to fillup the empty spaces.
package com.test.java;
public class sample {
public static void main(String[] args) {
int dupArr[] = { 1, 2, 3, 3, 7, 8, 8, 1, 4, 1};
int noDupArr[]...
How to test if a String is palindrome or not in Java?
Steps to check if a given string is a Palindrome or not?
Step 1: Get the string instance
Step 2: Reverse the string
Step 3: Compare the reversed string with the original string
Step 4: If it matches then it is Palindrome else not.
Below code snippet does the same thing:
package com.test.java;
public class PalindromeChecker {
public static void main(String[] args) {
...
JfreeChart Series-2: How to create a dynamic Pie Chart using JFreeChart library in Java
In the earlier tutorial I showed you how to create Bar chart using JFreeChart library. In this second article I’ll explain how to create pie chart. Everything is same like the previous tutorial, except the servlet code will be changed.
So let me first put the servlet code here:
package com.cts.chartgen.servlets;
import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
import...
File upload to BLOB field and display attachment dialog box
Sometimes a developer needs to provide the feature in their web application to upload file. This file can be anything like documents (PDF, doc, rtf etc.) or image (jpg, bmp, tif, gif etc.) or zip file. And after uploading the developer needs to provide another feature to download the file by clicking a link.
There can numerous ways to provide this functionality in a web application. I’m going...
