Running JSP with Mysql Database.

When you had the chance developing Jsp pages with Mysql as a database and Apache Tomcat 5.** as the back end server, and trying to run the simple database test connection and encounter the following error messages :

java.lang.ClassNotFoundException:com.mysql.jdbc.Driver

1st. If you are using IDE like eclipse or Netbeans, make sure you had include the java mysql connector jar file by the Eclipse right click on project look for Build Path and add the mysql .jar file into the library. Try and restart the apache tomcat server.

2nd. If it doesn’t work, copy the previous download mysql jdbc driver into directory one located at your apache tomcat common\lib folder; as C:\apache-tomcat-5.5.26\common\lib.

If this doesn’t work copy the file to C:\apache-tomcat-5.5.26\bin (i had no idea, basically i just copy and paste everything).

Restart the apache tomcat server and now it should be able to run!!.

Best firefox Extension for Web Developer

Here are the list of Firefox add-on plug-in I had been using for a while to test and debug for websites that I had been implemented, and not only that I can view a lot of buggy bad written Javascript (infinite loop) that make my precious Firefox Hang!!.
I think it is the perfect combination plug-in that a web developers must HAVE :

Web developer : A set of web development tools to help you imporve your coding, testing and debug.
Best tool ever. Get it from Web developer plug-in website.

Cache Viewer :Another great tool, to check the content of caches your browser are stored and track
the storage capacity was used. Basically it the GUI version of about:cache.
Get it from Cache Viewer plug-in.

Live Http Header : View Http header while browsing the web. Good to track the website you are visited.
Some say this tools can help you to track the port for private wifi WLAN such as
airport or public place but i haven’t try it yet. I used it to track the content send out
to the websites. Get it from Live Http Header plug-in.

FireBug : Ah, the master piece of css and javascipt plug-in to help you edit, debug and monitor the
performance of your script running on browsers. I really like this tool, because you can even
edit and execute javascript on the fly. Get it from here.

Book review #4

[Follow-up from previous post]

Novel
Finished Reading
Book Version : The Painted Veil
Movie Version : The Painted Veil

Author by : W. Somerset Maugham (Wikipedia)

This book was fantastic and sad. I don’t know how to describe it, i am not going to be a spoiler to tell the storyline (This post were will be very short because i really^2 do not wish become a spolier before you read it).

I really recommend this novel for person who are in Romance genres. But i think it is better to read the book first then only watch the movie.

Happy reading. 🙂

Book review #3

[Follow-up from previous post]

Technical Book

JavaScrip Bible

JavaScrip Bible



Javascript Bible Six Edition

Comment : This book is a MUST have for web developers. It made several important improvements over 4 edition. Example provided were very details and specifics. Ajax were covered as well.
The book is very thick like 6-9cm. Very good for beginner and amateur programmers.

Book review #2

[Follow-up from previous post]

Technical Book

Web Services : Author by Gustavo Alonso, Fabio Casati, Harumi Kuno, and Vijay Machiraju.

Comment : This book is really good for people who are new to web services and references as well. It explain the history of System architecture to current web services. Since this book is kind like a bit extreme technical like RFC specification and no practical solution at all. It introduce SOAP, WSDL, UDDI, 1 to N tier architecture, web service compsition, BPEL, WS-Security, WS-transaction, WS-routing, and more ws-*.

The first 1-4 chapters were about the enterprise system era before web services was introduced. You can got a big picture why integration and interoperability was so hard at that era.
Chapter 5-6, slowly walk through the needs of web services and chapter 7-9 were mainly about web service composition and BPEL was introduced.

Although i finish reading this book, i only get half of its content because this book was too technical for beginner. You had to understand each design behind the system before proceed to the next chapters. If you want to learn web services and don’t know where to start, then this book might help you.

Get HTML Title Tag using Java HTMLDocument Library

Java HTMLDocument model is to support both browsing and editing. If you had overcome need to parse HTML document and wanted to retrieve the title Tag child node value, you can’t use iterator to search the title tag and get the value. But there was one, even more easier way to do that.

//package needed.
javax.swing.text.html.HTMLDocument

//Sample code that get the html document from internet.
//We can use string instead.

URL url = new URL('http://yourwebsitehere.com');
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);

HTMLEditorKit htmlKit = new HTMLEditorKit();

//Only start from body
HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
.....
..... //Some HTMLEditorKit code here (Not used for this tutorial)
.....
String title = (String) htmlDoc.getProperty(HTMLDocument.TitleProperty);
System.out.println('HTMLDocument Title: ' + title);

//end java code here

This should be work, of course this is only the snippet code.

Reference : Java HTMLDocument API

Bypass Server Proxy with Java Code

Few days ago, i was writing Java Spider Web crawler that need to by pass by University proxy because of the firewall settings. Below here were the basic snippet code how we can bypass the proxy.

Java Library that needed :
import java.net.*;
import java.io.*;
import java.util.Properties;

Since we are using java property rather than compile with command as below :
UNIX
java -Dhttp.proxyHost=proxyhost
[-Dhttp.proxyPort=portNumber] URLReader

DOS shell (Windows 95/NT/XP)
java -Dhttp.proxyHost=proxyhost
[-Dhttp.proxyPort=portNumber] URLReader

Snipper Code :
//Place before you make a use of stream reader

Properties systemSettings = System.getProperties();
System.setProperty("http.proxySet", "true");

//Your proxy host server
systemSettings.put(“http.proxyHost”,”bluetongue.cs.rmit.edu.au”) ;

//Your proxy port
systemSettings.put(“http.proxyPort”, “8080”);

URL url = new URL(“http://www.google.com/news”);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

/* it’s not the greatest idea to use a sun.misc.* class
* Sun strongly advises not to use them since they can
* change or go away in a future release so beware.
*The username and password below ONLY be encoded that means
*it is not secure to transmit over the network. But since this is just a demo
*/

sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
String encodedUserPwd =
encoder.encode("mydomain\\username:password".getBytes());
con.setRequestProperty
("Proxy-Authorization", "Basic " + encodedUserPwd);

That’s all, you should be able to compile and run now.