Posts Tagged SCWCD

The life cycle of servlet

Tags: , , ,

Life cycle of servlet from the perspective of the container

1. After start, the container is looking for servlet classes in the appropriate directory (for Apache Tomcat would be $ TOMCAT_HOME / webapps) .

2. Once they are found, there are two possible ways: servlets are loaded immediately or only when someone wants to use them. By using term “load servlet” I mean the execution of its constructor and init () method. init () is executed only once in the life cycle of servlet . It allows you to prepare it for usage (eg to connect to the database, initialize any resources).

Code below presents fragment of web.xml file allowing to define order in which servlets are loaded when the containter starts:

<web-app>
    ...
    <servlet>
        <servlet-name>FirstToLoadServlet</servlet-name>
        <servlet-class>pl.tdziurko.scwcd.servlets.FirstToLoadServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>SecondToLoadServlet</servlet-name>
        <servlet-class>pl.tdziurko.scwcd.servlets.SecondToLoadServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    ...
</web-app>

Continue reading this post …


Be Sociable, Share!

Finally my SCWCD mission completed

Tags: , , ,

Much later than planned (check my post when I revealed intent to pass SCWCD) I managed to get this certificate. The result (94%) is in my opinion more than good :) Preparations began fairly long time ago (over a year ago) but since this time there were some unexpected circumstances (mainly project which seems to grew and grew) and that’s why SCWCD mission took me so long.

I started preparations as usual, by downloading specifications and adding API to Firefox bookmarks (list of links here). Then I bought Head First Servlets and JSP, the most recommended book for this certificate. I had ambitiously assumed that I will be able to write more detailed posts about what I learnt but unfortunately lack of time didn’t allow me to do it. Continue reading this post …


Be Sociable, Share!

Servlets – family of classes and interfaces

Tags: , , ,

Today I am going to present the most important methods, classes and interfaces in the Servlet API.

public interface Servlet

Main interface from which all starts. It defines key methods for the life cycle of servlet:


public void init(ServletConfig config) throws ServletException;
public ServletConfig getServletConfig();
public void service(ServletRequest req, ServletResponse res) throws ServletException, java.io.IOException;

public void destroy();

and one additional method


public String getServletInfo();

which should return information about servlet (version, author, resposibility, etc.) Continue reading this post …


Be Sociable, Share!

Let’s start preperations to SCWCD

Tags: , , ,

Here are some useful links, materials and books which I am going to use while preparing to Sun Certified Web Component Developer (SCWCD):

My aim is to pass this exam before July 2009 with result not lower than 80%.

Update:  And how it ended can be found in my another post – here.


Be Sociable, Share!