Thursday, January 21, 2010

A Journey Ends

Hello Everyone!

With a heavy heart, I have to state that this will be my last blog-post as a Sun Campus Ambassador. January 18th 2010 was a sad day here, at Sun Microsystems Inc. The Sun Campus Ambassador program has been closed all over the world as of Monday.

This announcement ended my wonderful 17 month journey in Sun as a CA. I joined in September 2008 and was a part of Sun till January 2010. The experience is unforgettable and is one of the best parts of my college life.

It would be very ungrateful on my part if I don’t express my gratitude to all the people who have helped me in this journey. I would like to thank everybody who has supported me throughout this program directly or indirectly.

Here is a brief review of my journey of 17 months in Sun.

All this started a year and half ago when my senior and the previous Sun CA of my college, Anil Kuppa graduated and inspired all of us to continue the legacy of the Sun Campus Ambassador program at our campus. He helped us to get in touch with Sun personnel and got interviews fixed for the interested students of my class. I would like to thank him for his guidance and his inspiring aura.

Initially I was guided by Ankit Srivastava and after he left, I came under Rajesh Uma Shankar. Rajesh was a big support in Sun Microsystems for me. Any problem, issue or question, a mail to him was enough. Rajesh has always been there for us and supported us at every moment. In this period I got an opportunity to meet other coordinators like Abhishek Kumar, Anuradha ma’am, etc. who have always led us in the right direction and have taken the Sun CA to a completely new level. Thank you everybody for your constant support and guidance. And a special thanks to Rajesh for everything he did for my college during IAP.

It would be incomplete to talk about the Sun CA program without mentioning Mr. Ganesh Hiregoudar, the program manager for the academic programs (APAC). Ganesh sir was a wonderful mentor and was very understanding. He always motivated us to reach new heights and taught us how to think out of the box. Thank you for everything, sir.

The best part of the Sun CA program was that we could meet a lot of like-minded people. We had an opportunity to collaborate with students from all parts of the country. We all were a team and took the CA program and OSUM forward at our colleges. I made a lot of friends and got to know a lot of people. On this parting day, I wish everybody the best of luck in their future endeavors and hope that someday our paths will cross and we will work together. I will miss you all. :(

One of the biggest element of my term as a Sun CA was OSUM. Big thanks to Gary, Tzel, Cecilia and Eze who have always supported us through OSUM and helped me complete my SCJP and SCWCD through the vouchers.

Throughout my phase as a Sun CA, my biggest support and the back-bone of my tenure as a CA was my college. During my first month, a new open source group, S.O.U.R.C.E, was started at my college with the support of Sun Microsystems Inc. We are greatly indebted to Prof. Venu Gopal Reddy, the principal of my college; Prof. S. Ramachandram, the head of my department when I started my tenure and Prof. Lakshmi Rajamani, the current head of the department for their cooperation in building up a vibrant open source community at my college.

My classmates are a few of the best people I have ever seen. I am extremely grateful to them for extending their helping hand in every event/competition at my college and standing by me at every moment in the past 17 months. I am also thankful to my seniors for their timely advices and great suggestions. My juniors have always been a great support and gave me the courage to do things as a Sun CA and I appreciate their help a lot. Thank you all for your incredible support and cooperation in helping me sustain Osmania University’s reputation at Sun Microsystems Inc. and bringing me to this position. If you go through my blog-posts here, you will realize how much Osmania University has done for me and the open source community.

Before I conclude, I would like to thank my parents from the bottom of my heart for their inspiration and unbeatable guidance and support throughout this period. I am grateful to God for giving me this opportunity and hope I have done justice to my role.

Finally, I will quickly list out the important mile-stones reached in the last 17 months -

  • Inauguration of S.O.U.R.C.E
  • Software Freedom Day 2008
  • The Ref Contest (Received accolades from several people and the idea was replicated in many countries)
  • Establishment of Sun FTP Server at Osmania University
  • Sun Tech Days 2009
  • Sun support in Infinity 2009
  • 18 internships from Sun Microsystems Inc. as a part of Industry Association Program
  • Software Freedom Day 2009

Besides these major mile-stones, Osmania University was a part of several competitions and technical sessions in this period.

My recognitions as "Sun CA of the month" and "Sun CA of the quarter" were the biggest honors for me at Sun.

Well, before I say goodbye, I would like to thank Sun Microsystems Inc. on behalf of Osmania University for giving us this opportunity and at the same time thank Osmania University on behalf of Sun Microsystems Inc. for their unvarying support and cooperation to the open source community.

You can reach me at and read my technical articles at And in case Sun pulls out this blog, I will replicate it elsewhere and provide the link at my tech blog.

Good bye.

Monday, January 11, 2010

Deploying Servlets & JSPs

Java Servlets & JavaServer Pages (JSPs) form the backbone of Web Application Development in Java. Java Servlet Technology and JSP are a part of the Java Platform, Enterprise Edition (JEE). The latest release of JEE (version 6), which was released a few days ago supports Servlets 3.0 and JSP 2.2. I am not going to emphasize the changes made in these versions here, but a quick Google search should give you an idea on the enhancements made.

A Java Servlet is primarily a class which conforms to the Java Servlet API, a protocol by which a Java class may respond to HTTP requests. A servlet may be used to add dynamic content to a Web Server using the Java platform. The generated content is commonly HTML, but may also be other data such as XML, etc. Similar non-Java technologies are CGI and ASP.NET.

JSP is a server side technology similar to that of Servlets. Like Servlets, it is also used to create dynamically generated web pages with HTML, XML, etc. in response to Web client requests. Architecturally, JSP may be viewed as a high-level abstraction of Java Servlets.

Though Servlets and JSPs are used to achieve the same goal, they were designed for two different profiles - developers and designers respectively. A well designed JSP may serve dynamic content using Java without any actual Java code in the JSP; this is achieved using other technologies of Java EE like Expression Language, Custom Tags, etc. Such a model was built to help Web page designers, who are good at HTML, build JSP pages without any need to understand the Java code involved. The developers can support these designers by building custom tags, developing the servlets in patterns like MVC, etc. If you are new to the world of Web Application Development in Java, this concept may seem a little overwhelming in the beginning, but as time progress you will understand this approach better.

To accept HTTP request and to give the users the required responses, a web/app server is used. A web server primarily accepts request and gives responses along with optional data content like images, etc. An extension to the web server is the app server. An app server can also expose business logic and business processes for third-party applications. Further, app servers have features like transaction management, security, etc. Apache Tomcat is a popular web server with Tomcat as the servlet container and GlassFish is a popular app server. Servlets and JSPs have to be deployed on these servers for the outside world to communicate with them. This post will be covering both these servers.

In this blog-post, I will be covering only the deployment phase of Servlets and JSPs. It is assumed that the reader is comfortable with Java and is well acquitted with the basics of JSPs and Servlets. I won’t be explaining any code in this post as most of it is self-explanatory.

Software needed

Note - Installing Java EE 6 will also install GlassFish v3.

To help the readers get a better understanding of the entire process, I will be developing a simple Hello World Application with a Hello World JSP and a Hello World Servlet here.

Here are the source codes of the JSP and the Servlet -

Compile the servlet using the javax.servlet.jar available in glassfishV3\glassfish\modules directory, which is obtained after installing JEE 6 with the following command -

javac -classpath install_path\ glassfishV3\glassfish\modules\javax.servlet.jar

Understanding the directory structure

Every web application has a typical directory structure. The JSPs and Servlets along with the required descriptors have to be placed in this directory structure. I will emphasize this structure using the Hello World example. The structure is as follows -

Any file/folder present in the root of the Web Application (like helloWorld.jsp) here is directly available to the client. Even folders present here (except WEB-INF and META-INF) are available directly to the users.

The root also contains a directory called the WEB-INF. This is a required directory and contains three important sub-folders - classes, lib and tags. Every web application also has a deployment descriptor (web.xml). This is also placed here.

The classes directory contains the .class files. The servlet class files are also placed here (like HelloWorld.class).

The lib directory contains any external JAR files that are used in the web application. In this example we have no files in this directory.

The tags directory contains the TLD along the .tag files. As this is an introductory example, we will keep this directory empty. If there are any custom tags being developed in the web application, they should be placed here.

The deployment descriptor defines the mapping between the servlet name and the servlet class.

Download the entire application here.

Deploying the application in Apache Tomcat

Copy the directory HelloWorldApplication built in the above step to the webapps directory of Tomcat i.e. install_path\Apache Software Foundation\Tomcat 6.0\webapps.

Start Tomcat from install_path\Apache Software Foundation\Tomcat 6.0\bin\tomcat6.exe.

To view the JSP page, type http://localhost:8080/HelloWorldApplication/HelloWorld.jsp in the browser and to view the servlet page type http://localhost:8080/HelloWorldApplication/HelloWorld in the browser.

Shut down tomcat6.exe to stop the server.

Deploying the application in GlassFish V3

Start GlassFish using install_path\glassfishV3\glassfish\bin\startserv.bat.

Open http://localhost:4848/ in the browser.

Login with the admin password and navigate to Applications Task in the left-side panel. Click on deploy and select "Local Packaged Directory" and specify the directory built above.

Select the type as "Web Application" and click on "Deploy".

To view the JSP page, type http://localhost:8080/HelloWorldApplication/HelloWorld.jsp in the browser and to view the servlet page type http://localhost:8080/HelloWorldApplication/HelloWorld in the browser.

Stop GlassFish using install_path\glassfishV3\glassfish\bin\stopserv.bat.

That’s it. We have written a web application and deployed it on Apache Tomcat and GlassFish. Still there is one more catch - what if I have to move the web application from one physical server to another physical server? Do I have to build the directory structure again? Well look for the solution in my next blog-post - Building Java Web Archives (WARs).

Monday, January 04, 2010

Sun Certified Web Component Developer

I recently attempted the "Sun Certified Web Component Developer for the Java Platform, Enterprise Edition 5" exam and passed it flawlessly.

The SCWCD exam is primarily for developers specializing in the application of JavaServer Pages and Servlet technologies used to present Web Services and Dynamic Web Content.

The certification tests the developer if he/she understands the basics of JavaServer Pages and Servlet technologies along with the best practices of the Web Application development. The exam also covers a few extreme features like JSTL, EL, design patterns, etc.

The certification, as of today is available in only one flavor - 5 (also known as 1.5). However to attempt the SCWCD exam, one must be a SCJP. Know more about SCWCD at

The "Sun Certified Web Component Developer for the Java Platform, Enterprise Edition 5" exam covers objectives like -

  • The Servlet Technology Model
  • The Structure and Deployment of Web Applications
  • The Web Container Model
  • Session Management
  • Web Application Security
  • The JavaServer Pages (JSP) Technology Model
  • Building JSP Pages Using the Expression Language (EL)
  • Building JSP Pages Using Standard Actions
  • Building JSP Pages Using Tag Libraries
  • Building a Custom Tag Library
  • Java EE Patterns

The exam actually costs Rs.7200, but being a Sun employee I got it for free under SAI. :)

A minimum of 70% (49 questions out of 69) is required to clear the exam. And the time duration for the exam is 3 hours.

For preparation of the exam, here is the material that I followed; I think this should be enough to get a respectable score -

Head First Servlets and JSP: Passing the Sun Certified Web Component Developer Exam - Kathy Sierra & Bert Bates

This is a comprehensive book for the SCWCD 5 exam, it covers all the objectives of the exam in a structured approach. Anybody attempting the exam should go through this book at least once.

Buy the book from at