Archive

Archive for May, 2007

Back Home !!!

May 29th, 2007 Arun Manivannan No comments

Back to my beautiful bungalow in Saidapet — filled with dust and love. Sister’s marriage got over. Be back in chennai office on Thursday. This also means the restart of scribbling on this big sheet of paper.

And if you really wanted to ask what i learnt these days, here are sample pics

Dont beat around the bush

Water is scarce (to the throat at least)

Looks are deceptive

THE GRASS IS ALWAYS GREENER ON THE OTHER SIDE OF THE FENCE

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis
Categories: Uncategorized Tags:

“THE” Lucene Tutorial

May 18th, 2007 Arun Manivannan 2 comments

I feel ashamed to tell that I am just now putting my head into learning Lucene.  “Never too late”, I am trying to tell to myself.

Here is one beautiful tutorial on Lucene.

Tutorial by Steven J Owens

Please do refer to this page too 

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis
Categories: Uncategorized Tags:

Hold variables across page refreshes in Javascript — The infamous “Close All” functionality

May 18th, 2007 Arun Manivannan No comments

Expandable sample

Say, you have an expandable menu (like the one in picture but the expansion is not Javascript driven) on the parent window and the parent window refreshes on every click of the node of the menu (the (+) and (-) kind of menus). You also have a “Close All” button on the parent window which is supposed to close all the child windows.

Ideally, you want to hold the names (or handles) of the child windows in order to close all the child windows when the “Close all” button is pressed. But since the parent window gets refreshed on menu node expansion, the Javascript array of child handles that i have disappears.

Bottom line, Javascript variables get reinitialized on page refreshes. But there is a workaround for this.

You can simply assign the array to a special variable called navigator.storedvariable

Something like,
navigator.storedvariable=windowNames; // windowNames is the array of names of the child windows.

This is the exact code i wrote for implementing the Closeall functionality

function closeChildWindows(){//retrieve all the names of childwindows
var childWindows = navigator.storedvariable;
if ( childWindows != null ){

//loop through each of the window
for (var k=0;k<childWindows.length;k++){
var openedWindowName = childWindows[k];

//Open all the child windows since we have already lost handles and then close again. The browser will open the child window in the same previous (stale) browser child window

winHandle = window.open(”,openedWindowName,’toolbar=0,location=0,width=2,height=2,scrollbars=no,resizable=no,directories=0,status=0,menubar=0′);winHandle.blur();
//as soon as you open, close them. So that the user doesnt realise that the same browser was used again

if( winHandle && winHandle.open && !winHandle.closed)
{
winHandle.close();
}
}//end of for loop

} // end of childwindows!= null
//after closing all windows, reinitialize navigator.storedvariable
windowNames=new Array();
navigator.storedvariable=windowNames;
}

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis
Categories: Uncategorized Tags:

Junk values during Excel export/Image display

May 11th, 2007 Arun Manivannan 1 comment

I happen to face this problem a year back.  I was expected to show an image on a JSP which is stored as a BLOB in the database.  (I also wrote another post a few days back with uploading and showing image from a MySQL database (with Hibernate)).  The problem I faced a year back was that i was displaying junk values on the page instead of the image though the MIME type was set as “image/jpeg” and  the output stream flushed.

The same kind of problem my friend faced last week when he was trying to extract information from the database and export it as excel sheet.  He used Apache POI for constructing the workbook, set the MIME type as “application/vnd.ms-excel” and flushed the output stream. But what got exported was just junk values.

The reason was that only the ServletOutputStream was flushed out. Not the response. As you already know that in Servlets, the response does not get flushed automatically (unlike JSPs). So, here comes the need for response.flushBuffer();

Here is the core code.

response.reset();

response.setContentType(“application/vnd.ms-excel”);response.addHeader(“Content-Disposition”,“filename=TableList.xls”);

 

ServletOutputStream stream=response.getOutputStream();

wb.write(stream);

 

//flush output stream

stream.flush();

 

//please dont forget to flush the response

response.flushBuffer();

 

//need to close the stream now. .

 

stream.close();

I developed a small sample application. Please dont mind the architecture or performance of the code. Download the entire source code.

Please note that I have not defined any welcome-files. Point your browser to export.jsp. (PS :Application works only against Oracle databases) 

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis
Categories: Uncategorized Tags: , , , , ,

Working with Apache Derby

May 10th, 2007 Arun Manivannan No comments

As you know, Java 6.0 comes bundled with Apache Derby.  The “db” folder inside the JDK 6.0 directory is our bundled Database. Here is the list of things i did on the db.

1) Connect 

    But before connecting we need to set the classpath for Apache Derby. Just add the following lines to your classpath.

     $JAVA_HOME\db\lib\derby.jar;$JAVA_HOME\db\lib\derbytools.jar;

    Basically, the derby.jar is the core apache derby db purely written in Java. (comes around 2 MB).  More on Apache Derby >>

    And the derbytools.jar gives one interesting tool called the “ij” for that command line db access.

      java org.apache.derby.tools.ij  will give you a “ij” prompt.  Type help and you will get a list of commands you can play with.

      ij> help;

ij help list of commands

      Finally, to connect to a database, use the following command.

      connect ‘jdbc:derby:myfirstdb;create=true’;

     The String following the “connect” keyword just tells us that you are using org.apache.derby.jdbc.EmbeddedDriver (jdbc:derby) to connect to myfirstdb (your database), which has not been created yet. So you create it (create=true).  So, the next time you want to connect to the same database, connect ‘jdbc:derby:myfirstdb’ ; will do.

2) Create table

ij> show tables;

TABLE_SCHEM |TABLE_NAME |REMARKS

————————————————————————

0 rows selected

ij> create table emp (empname varchar(20), empno int);

0 rows inserted/updated/deleted

3) Insert a row to table and query it

ij> insert into emp values (’arun’,101);

1 row inserted/updated/deleted

ij> select * from emp;

EMPNAME |EMPNO

——————————–

arun |101

 

1 row selected

>>more on how to use Java to connect to Derby in embedded and network mode 

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis
Categories: Uncategorized Tags:

Radio on Software Engineering?

Radio for Software Engineers? That’s a great idea. And here is the idea come real at http://www.se-radio.net/.  And dont miss episodes 37 and 43 on Extreme Programming.

Software Engineering Radio

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis
Categories: Uncategorized Tags:

Windows Vista Home Premium — Unable to uninstall software

May 1st, 2007 Arun Manivannan 6 comments

Yeah. This is a post on Windows Vista by a Linux user. (I am forced to use Windows temporarily due to this Flex Builder trap by Adobe). I bought this Dell Inspiron notebook which came bundled with Vista Home premium. I was trying to uninstall some useless software and I got this error.

“The system administrator has set policies to prevent this installation”

Vista Home Premium uninstall

Called up Microsoft support and the Dell support. No use.

Here is the fix i found from this site.

1- Click Start, and type “cmd” in the search area, right click on “Command Prompt” and select “Run as Administrator”.

2- In the command prompt type “net users Administrator /active:yes” (Note the capital “A” in Administrator) and press Enter, you will get a confirmation as “The command completed successfully”.

3- Click Start, and type “regedit” in the search area and click Enter, navigate to:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
Double click on “FilterAdministratorToken” and set it to “0″
Log off and you will have your Administrator account activated. Login in and uninstall.

Linux is always sweet here. First, you can just “sudo” to Administrator. And second, you need not to log off/restart for anything.

Vista Ultimate users, you always have the gpedit.msc. Forgot to mention something, I am not able to use my Nortel Contivity client on Vista. However, There is a beta version for the client here. Try your luck.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis

Why did a Microsoft employee switch to Linux?

Read this very interesting article “When did i stop being creative?”

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis
Categories: Uncategorized Tags: , ,