February 11th, 2011
774 views
Normally people start feeling their responsibility once they cross age of 30 or when they got married. But some out of them starts planning their budget from the initial halt of their life. Like me…. Ha ha ha..
If you are not very good in finance and avoid bulky & boring clerical work then below excel templates would help you surely to plan your budget
Halt 1 : Personal Budget Planning

Halt 2 : Wedding Budget Planning

Halt 3 : Family Budget Planning

Halt 4 : Kids Money Management

February 9th, 2011
589 views
If you are planning to validate a file over its size at client side only using some java script then SORRY.

Listen
Listen
Listen
You need not to be disappointed. I have many solutions
- ActiveX control
Write the following code in script tag in your HTML.
function getSize()
{
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
var filepath = document.upload.file.value;
var thefile = myFSO.getFile(filepath);
var size = thefile.size;
alert(size + " bytes");
}
Please note this
Use of ActiveX control is always avoided due to security reasons.
- Java Applet – I had written a Java applet. But i’ll prefer to write a separate code for the same.
- SWF – I haven’t tried it before. But it is a very good option.
- .htaccess
Write following line in your .htaccess file.
LimitRequestBody 2097152
Apache error log will generate this entry when you exceed this limit on a form post or get request:
Requested content-length of 4000107 is larger than the configured limit of 2097152
And it will also display this message back in the web browser:
<h1>Request Entity Too Large</h1>
By the way, the error number returned is 413. So, you could use a directive in your .htaccess file.
Redirect 413 413.html
- Best way:
Let client upload the file. Don’t write it at server end immediately. Instead,
- Create a file progress bar who monitors how much part of a file has been uploaded.
- Once it crosses maximum specified size limit;
- Leave writing
- Prompt the client.
Now see how to implement this logic in Java
1
Download following jars
- commons-fileupload-1.2.1
- commons-io-1.4
You will get them easily on apache sites.
2
Add following code in your java class say
servlet.
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.*;
import org.apache.commons.io.*;
3
Following line will help you to identify whether client is uploaded a file or not.
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
4
If yes then first read all the values through some iterator. And check whether there is any non form field (means whether the current item is a file)
Object img = itr.next();
FileItem item = (FileItem) img;
if (!item.isFormField()){
:
}
5
Now its up to you whether you write a file on your server immediately. Or Byte by Byte. I’ll suggest for second option.
byte[] boundary = "article-stack.net".getBytes();
//byte[] boundary = new byte[1000000]; //geting hanged by defining fixed no of bytes
try{
MultipartStream ms = new MultipartStream(item.getInputStream(),boundary,1000);
FileOutputStream fileOut = new FileOutputStream(savedFile);
ms.readBodyData(fileOut);
fileOut.flush();
fileOut.close();
}catch(Exception exp)
{
savedFile.delete();
exp.printStackTrace();
}
6
Its not done boss. You have to write a progress listener.
ProgressListener progressListener = new ProgressListener(){
private long megaBytes = -1;
public void update(long pBytesRead, long pContentLength, int pItems) {
long mBytes = pBytesRead / 1000000;
if (megaBytes == mBytes) {
return;
}
megaBytes = mBytes;
System.out.println("We are currently reading item " + pItems);
if (pContentLength == -1) {
System.out.println("So far, " + pBytesRead + " bytes have been read.");
} else {
System.out.println("So far, " + pBytesRead + " of " + pContentLength
+ " bytes have been read.");
}
}
};
Modify the above progress listener as per your need to limit the file size.
Happy……..
Categories: How & Why, Interactive knowledge & Tips n Tricks & other reference stuff Tags: beginner, computer, how, HTML, intermediate, Java, Ready to use, Snippet, Tips & Tricks, tutorial, web
February 6th, 2011
985 views
I am lazy to read books……….
Are you a Hindi blogger?
Or you wanna search something equal to your Hindi words?
Till 5 days ago, I used to visit translate.google.com to find out English word. I put Hindi words there. In 60% cases Google suggests be near about word. I put it into Wordweb to check whether it matches to my need.
Now I have an online dictionary who gives me proper result and multiple options to select correct word. It keeps me away from any other dictionary.
See the Screenshots against word “Satyata” in different search. And select which one fits to your need.




*Best feature of theses dictionaries is, you can search for more Hindi words using English or Hindi search directly.
February 2nd, 2011
229 views
Whenever a new currency symbol gets registered, Unicode is assigned to this. So people can use it in their application. But they need to update their application so that their applications can support new unicodes. Some people and organizations are supposed to use old version of applications due to licensing issue. Or because, updating to new version of application may need update in many existing resources.
On the other hand, using an open source font in your application is not only easy but it’ll require no changes or update in existing resources. In addition, it’ll minimize the effort too.

Best feature of this font is OPEN SOURCE (under GPL). You are free to use it in personal or corporate applications.
Why to use Amty Currency Font instead of Images?
Many of the website designers start using images to display currency symbol at their site. Amty Currency Font is a good replacement of this.
- If you are aware with SEO concepts, there is an extra http request is required for each image on the page (single request for repeating images).
- Size of the images is always greater than fonts.
- You can display fonts in any size, any color with any background color.
- You can use them to generate complex CAPTCHA images.
January 28th, 2011
220 views
There is sample servlet code which read request parameters and response them back. This servlet will give you an idea about how a servlet looks. And how to process request parameter.
You must remember while writing a servlet that servlet is nothing but a special java class. Outside application whether your webpage or any other standalone application access a servlet by its alias name. This naming conversion has written inside a file say web.xml. Your server identifies the request and link it to proper servlet. So basically you need 3 components
- Servlet class
- web.xml
- some webpage to hit your servlet
Sample Servlet
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Map;
import java.util.Iterator;
import java.util.Map.Entry;
/**
* This servlet accept form String data.
* 1. Prints values of text box having name username,department and email
* 2. Prints values of any form field having any name (including multiple selector, check boxes etc.)
* 3. A form element having no name can not be accessed any way (parameter name, parameter map)
* @author Amty
*/
public class ArticleStackPostHandler extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
/* Use the ServletRequest.getParameter(String name), getParameterMap(), getParameterNames(), or getParameterValues() methods in the servlet's doPost method*/
String name = request.getParameter("username");
String depart = request.getParameter("department");
String email = request.getParameter("email");
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Welcome</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Your Identity</h1>");
out.println("Your name is: " + ( (name == null || name.equals("")) ? "Unknown" : name));
out.println("<br><br>");
out.println("Your department is: " + ( (depart == null || depart.equals("")) ? "Unknown" : depart));
out.println("<br><br>");
out.println("Your email address is: " + ( (email == null || email.equals("")) ? "Unknown" : email));
out.println("<h2>Using ServletRequest.getParameterMap</h2>");
Map param_map = request.getParameterMap();
if (param_map == null)
throw new ServletException("getParameterMap returned null in: " + getClass().getName());
//iterate through the java.util.Map and display posted parameter values
//the keys of the Map.Entry objects ae type String; the values are type String[],
//or String array
Iterator iterator = param_map.entrySet().iterator();
while(iterator.hasNext()){
Map.Entry me = (Map.Entry)iterator.next();
out.println(me.getKey() + ": ");
String[] arr = (String[]) me.getValue();
for(int i=0;i<arr.length;i++){
out.println(arr[i]);
//print commas after multiple values,
//except for the last one
if (i >= 0 && i != arr.length-1)
out.println(", ");
}//end for
out.println("<br><br>");
}//end while
out.println("</body>");
out.println("</html>");
out.close();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
doPost(request,response);
}
}
Sample web.xml
<servlet>
<servlet-name>ArticleStackPostHandler</servlet-name>
<servlet-class>ArticleStackPostHandler</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ArticleStackPostHandler</servlet-name>
<url-pattern>/PostHandler</url-pattern>
</servlet-mapping>
Sample web page to hit this servlet
<%--
Document : index
Created on : Jan 23, 2011, 2:54:06 PM
Author : Amty
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1><a href="http://article-stack.com/">Article-Stack.com</a></h1>
<form action="PostHandler" method="post">
<p>username:
<input type="text" name="username" value="" />
<br />
department: <input type="text" name="department" value="" />
<br />
email: <input type="text" name="email" value="" />
<br />
</p>
<p>color:
<input type="checkbox" name="color" value="RED" checked="checked" >RED</input>
<input type="checkbox" name="color" value="GREEN" >GREEN</input>
<input type="checkbox" name="color" value="BLUE" >BLUE</input>
</p>
<p>
<select name="cities" size="3" multiple="multiple">
<option>Mumbai</option>
<option>Bangaloor</option>
<option>Chennai</option>
<option>Delhi</option>
<option>Indore</option>
</select>
</p>
<p>
<input type="submit" value="Submit" />
</p>
</form>
<h1> </h1>
</body>
</html>
January 17th, 2011
196 views
Worrying about your coming old age, retirement, and pension or saving?
People starts saving once they start earning. But it becomes difficult to figure out whether their saving is enough for their retirement after all big expenses like marriage, medical etc.
Below retirement calculator excel template shall help you to compare two or three different Savings Plans and help to choose the right plan for you.

*click above image for downloading
January 12th, 2011
613 views
If you are not willing to use log4j configuration file ie log4j.properties then you will have to define a java class to set all properties in your code itself.
STEPS
- Creating a logger and appender. Add appender to logger.
- Set the LEVEL if you want
- Define log message layout.
- Don’t forget to attach log file path where you have to write your messages.
Sample code: Copy and paste below sample class somewhere in your java project.
public class Log
{
public static Logger as_looger;
public Log(){}
static
{
as_looger = Logger.getLogger("articles logging");
// as_looger = Logger.getLogger(Log.class.getName());
FileAppender as_appender = null;
as_appender = new DailyRollingFileAppender(new PatternLayout("%d{dd-MM-yyyy HH:mm:ss} %C %L %-5p: %m%n"), “path of file where to write logs”, "'.'dd-MM-yyyy");
as_looger.setLevel(Level.DEBUG);
as_looger.addAppender(as_appender);
}
}
Since as_looger is declared as static in above example class. So you can use it throughout your java project using class name as follow;
Syntax
< Log class name >.< logger name >.< method denoting a level >(“message”);
Example
Log.as_logger.debug(“article-stack.com has been started.”);
January 10th, 2011
2743 views
Preparing a classical ugly textual report using some word editor may make your impression down in your supervisor attention. On the other hand, if you prepare a report containing charts, graphs, figures and data arranged in tabular format then it may require extra technical knowledge and time.
Well!! I have solution for both. Use below excel templates which can minimize your official documentation work as per your need.
1
Timesheet
2
Timeline
3
Gantt Chart
4
Critical Path Method
5
Vacation
January 9th, 2011
338 views
- Ever wondered what it may take to come out of a credit card debt?
- How long it will take to pay off credit card balance with and without making more monthly payments?
- What to do to pay off faster?
- Handout the below excel template Credit Card Payoff Calculator which can help you to answer above questions
With help of this calculator it will be easier to figure out the ways to completely pay off your credit card debt and helps to understand just how much it can really cost you in interest.

*click above image for downloading
January 9th, 2011
3956 views
If you know how to work with excel then these working sample excel templates shall give you better experience. Here are some excel templates to schedule your weekly,monthly or yearly work, shifts etc. effectively.
A good reason about working with excel sheet is, you need not to install any software.
Download the below excels and organize your time. All the best.
1
Schedule your work
2
Organize work assignments for an entire week
3
Schedule the week
4
Baby feeding Schedule
December 13th, 2010
78 views
Many visitors are never interested to download the contents first then check them. They want to take snapshot about the contents from your site/article/post itself. You must help them to view documents online instead of downloading any document to their local PC or to installing any plugin. It’ll remove an overhead from your visitor and will increase hits on your site.

What you need to embed
- Word document
- Power point presentation
- Excel worksheet
- PDF documents
- Video
I already had suggested about how to embed documents using google . But if you want to avoid any manual intervention then TGN plugin (for wordpress users) would be a good option.
How to use TGN
While writing an article, you can use short code to embed any document on your page. TGN must be installed in advance.
YouTube
[ youtube article-stack]
VideoReadr
[ videoreadr article-stack]
PDF
[ pdf article-stack]
PowerPoint
[ powerpoint article-stack]
Microsoft Word
[ word article-stack]
Note that: remember to replace “article-stack” keyword with valid link for your documents or video ID.
December 12th, 2010
170 views
Many people search for plugins to add support of jquery based thickbox. But do you know this is already included in your wordpress bundle. Let’s try

Suppose you want to open a webpage into thickbox. Just add following code at the end of last link we made above
&embedded=true&KeepThis=true&TB_iframe=true&height=400&width=650
And add following code to your anchor tag.
class="thickbox"
For Example
For more guidance, refer jquery thickbox
December 11th, 2010
173 views
There is the list of highly searched keywords in year 2010.
Are you not able to read above document? Read it here
November 8th, 2010
198 views
Ms Swati constructed a static website for their customer. She received hundreds of complaints within 1 hour of launching. All the complaints were related to mess-up design. She was the victim of compatibility issue of java script & CSS across many browsers and screen resolution.
This is sample text inside a rounded corner box made by jpg images.
I seen many people use java script & css to display rounded corner box. Or they make their web pages heavy using PNG images. PNG images again require
PNG fix for some browsers. And these fixes are not 100% fool proof. These fixes again increase overall size of web page.
Better solution is to use GIF images instead of PNG. Because their transparency is preserved across browsers. Or you can go for 2 color images for rounded corners. See the sample in side.
You can make images for corners using any image editor. Otherwise use online service for the same.
This online script let you generate any color images matching to your page background along with CSS code. So you can make any rounded corner box within some minutes.

October 24th, 2010
9635 views
Your first documents to build a payroll system must have been finished. And hopefully all of you already had been switched to coding part. Still if some of the part is missing or you just want to reconfirmed and if you are going through oops then the below class diagram may be useful till some extension.

Special thanks to Mr. Barry Williams.
Read an analysis report over payroll system with diagrams.
October 24th, 2010
17197 views
Hey students!!
This is the time to complete your project analysis. And get involved into coding. I hope many of you already had submitted your analysis report in your college. You must already had designed the database. Still I will suggest you to recheck it.
If you are building an application or project on HR management where payroll is one of the part of your big project or if you are developing an independent project on payroll or salary management system then Craig Borysowich analysis may help you a lot.


One of the structure chart and data flow diagram are given above from the Craig Borysowich report. For detailed reading and more level of above diagrams visit
.
Special thanks to Craig Borysowich, for his valuable analysis.
See class diagram for the payroll system.
October 7th, 2010
59 views
DB2
select *
from (select rownumber() over(order by <colName>) as row_num, <colName2>
from <table name>)
as <alias name>
where row_num < N+1 with ur
Oracle
select *
from (select rowid as row_num, <colName2>
from <table name>)
as <alias name>
where row_num < N+1
October 6th, 2010
115 views
DB2
select *
from (select rownumber() over(order by <colName>) as row_num, <colName2>
from <table name>)
as <alias name>
where row_num = N with ur
Oracle
select *
from (select rowid as row_num, <colName2>
from <table name>)
as <alias name>
where row_num = N
October 6th, 2010
127 views
DB2
select *
from (select rownumber() over(order by <colName>) as row_num, <colName2>
from <table name>)
as <alias name>
where row_num between 1003 and 1118 with ur
Oracle
select *
from (select rowid as row_num, <colName2>
from <table name>)
as <alias name>
where row_num between 1003 and 1118
September 27th, 2010
106 views
If you are having internet and less time to build any application for testing Regular expressions then you can go for online tester. You just need to copy paste your contents. Write appropriate regular expression. And see the result.