Saturday, July 28, 2007

Beyond Sun Java Certification

came across this site
http://www.javablackbelt.com/
someting i was always looking for ...
certification by sun on java includes only basic things
not popular framework like spring , hibernate ..

nice job friends !!

Cool Tool to colorize code

Hi
my friend suggested me this cool tool ...
i wanted to colorize my code .. using the color scheme as in IDE
this is cool copy cust paste tool ...
sth we all programmers (??) are used too
http://www.chami.com/colorizer

he he he

Good Servlet Bad Servlet

lest try to code the same servlet in good way and bad way


public class Bad_Servlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
// BAD : this line created one more java object to be GC

public void init(ServletConfig config)
throws ServletException
{
super.init(config);
System.out.println("LOG : Init called");
// BAD : using sop is bad it will require Servlet
// to synchronize disk actions and http response.
}

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String output="<html>";
output+="<head><title>Bad Servlet</title></head>";
output+="<body>";
output+="<p>The servlet has received a GET. This is the reply.</p>";
output+="</body></html>";
// BAD : pat ur backs once if u judged using variable will create one
// more object for Garbage Colection PAT ur back many times if u judged
// that using + operator with "temp" will cr8 many temp string objects 4 GC

out.println(output);
out.close();
}

//BAD : overriding destroy() will help u freeing ur resources ..
// that will reduce burden on webServer GC cant go ahead until
// it is sure resources re free
}



now the same code in Good servlet


public class Good_Servlet extends HttpServlet {

public void init(ServletConfig config)
throws ServletException
{
super.init(config);
}

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Good Servlet</title></head>");
out.println("<body>");
out.println("<p>received a GET. This is reply.</p>");
for ( int i = 10; i > 0; i-- )
{
out.print( "<h1>" );
out.print( i );
out.println( "</h1>" );
out.flush();
// make sure the browser see the count
// another use of using println()
try
{
Thread.sleep( 1000 );
// this loop takes time
// BUT user wont experience difference
}
catch ( InterruptedException e ) { }
/*
If a page contains a number of graphics
(in a header, for example), each of those graphics
needs a separate HTTP request to be loaded.
If the servlet calls flush() after writing the
IMG tags for the graphics into the PrintWriter,
the browser can start loading the graphics
while the servlet is still processing the original request.
This reduces the amount of time required to display the
complete page in the browser because the separate requests
can be handled concurrently.
*/

}
out.println("</body></html>");
// The difference here is that all output is written directly
// to the PrintWriter, which does not require creating any
// intermediate objects
out.close();
}

public void destroy(){
}
}

Monday, July 2, 2007

Guruji .... a guru ??

came accross http://www.guruji.com/ the first thing i did not like is the punch line ...
"the indian search engine"
guys why do you want to regionalise technology ... and why are people trying to cash on region wise ... its a big world out there ... go compete.... may the best technology win ... !!

and the funnier part ...
try searching ... "flex coders india" ( mind you tried searching something specific to india )
and the FIRST result i got was ....
http://www.punebusinessdirectory.com/BuyingSelling/ShowProductEnq.asp?ProductID=962
based on following highlighted text
(Baddi, distt-solan , INDIA) BUY CODERS PRINTERS Details REQUIRED RENUKA ENTERPRISES (KHAMGAON , INDIA) FLEX BOARD INKJET JET PRINTER

man that was pathetic ...
try the same on THE Search Engine .. i mean google ... and u get
http://www.flexcoders.net/ ( international registry for flex coders )
and second result ...
google group ... groups.google.com/group/bombayflexcoders
second is more relevant than 1st ...

and DEFYING the "dont be eveil motto"
guruji started a contest ... for everyine to use there search engine .. and win prizes
ok ... quite a few people will start using this service if promoted like this
but what after the offer is gone ..
WHY WOULD SOMEONE USE SEARCH ENGINE THAT GIVE INAPPROPRIATE RESULT ...

as the saying goes ... 1st impression is the last impression ...

all i can say is that
(i) guruji u need improve a lot ...
(ii) guruji pls dont bias in terms of regionalism ...
(iii) dont bribe guruji ... that is not good in long term ...

hope to see gurji in better shape soon
cheerz !!