Saturday, November 17, 2007

JSP Servlets - Explanation

Now that I've posted a full-fledged tutorial, I guess there's some explanation that needs to be done. If you are new to servlets (or Java/JSP, for that matter), please look up resources on the net. A good place to start would be http://java.sun.com/ So now, for those familiar with servlets and their use, here goes...

After having developed test websites in ASP for years, i had finally hit a road-block. The road-block was that even after separating the 'processing logic', from the display related stuff, I was still stuck with having to put everything in an HTML page. I saw the solution in servlets.

So, on 15th November 2007, I finally took the big leap, and made the switch to JSP. I started up a new project, SAMS - Standard APIs for Mobile Services. I vowed not to touch ASP, no matter what.

It wasn't easy. I had developed a certain comfort level with ASP, kind of a relationship.. Now I had to start over again with some'one' else. But start I did. It began with the most frequently used include directive. The next major hurdle I wanted to cross was database connectivity. I managed to set the JDBC:ODBC things straight after a few Google searches. JSP, for now, was done. It was up and running, and that was sufficient for me.

Now, it was time for me to move on. And I saw 'servlets' as the next step. I got a sample servlet file, and tried hard to compile it in JCreator, which would keep giving errors of library not found. Googled hard again, but to no avail. Then somehting struck me.....it might require Java EE. Looked that up, and found out that my guess was right.

Downloading EE was quite a decision. I don't have unlimited downloads on my plan. 1GB a month. That's it. I was at the middle of the month, with 485 GB (nearly half) used up. EE would add another 90 MB. After deliberating a bit, I reckoned it would be money well invested. SO I went forth and downlaoded EE.

Tomcat was set up previously. EE was installed. I had everything running. My servlet was supposed to work. But it didnt. My servlet had compiled alright. But i didnt know where to put the class file. Googled again. Googled hard. Found the configurations to be made to the web.xml file. Did them, and voila, finally, it was running!!!

I had spent a good 4 hours researching and implementing my first servlet. It was 12:30 a.m. of 16th Nov 2007. Was tired already, but though of documenting everything. Wasn't blogging then. So composed a mail to myself.

That mal is what has been posted as the previous blog. Hope that it will be useful to a lot of newbies out there.

Cheers!

No comments: