Archive for April, 2009

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!

Pełne archiwum SDJ 2008 i 2007 do zgarnięcia

Tags: , , ,

Dear Reader
This post is in my native language as it applies only to developers society in Poland. Please feel free to check my other posts which are mainly written in English.

Dzisiaj do mojej skrzynki wpadł newsletter od Software Developer’s Journal. A w nim:

Archiwum SDJ za darmo

Maj za pasem. Zbliża się długi weekend, więc większość z Was na pewno jest w świetnych nastrojach ;-) Aby jeszcze bardziej poprawić Wam humor, mamy dla Was niespodziankę!

Wszyscy, którzy w dniach 30.04 – 5.05, kupią najnowsze wydanie Software Developer’s Journal 5/2009 i prześlą na adres: lukasz.lopuszanski@software.com.pl  zeskanowany dowód zakupu, otrzymają:

Kompletne archiwum SDJ 2008 ( obejmujące również numery EXTRA )w formacie PDF, oraz kompletne archiwum SDJ 2007 ( wraz z numerami EXTRA ) w formacie PDF!

Wszystkich serdecznie zapraszamy do skorzystania z tej wyjątkowej okazji.
Udanego wypoczynku!!!

Redakcja SDJ

I nawet jeśli uważam, że dla programisty Java regularne kupowanie SDJ nie jest konieczne ze względu na bardzo szeroki zakres prezentowanych zagadnień i częstą sytuację, że ciekawe/przydatne są 1-2 artykuły w numerze to sam pomysł z udostępnieniem pełnego archiwum z dwóch lat w zamian za kupienie majowego wydania bardzo mi się podoba i mam zamiar z takiego prezentu skorzystać :)


Be Sociable, Share!

NNTP, Apache Commons and non-US charaters

Tags: , , , , ,

Like every weekend, today I was spending time on writing application for my MSc thesis. Among few tasks I planned for today one was connected with sending messages/notifications to the internal discussion group of my dormitory using NNTP protocol.

Short research showed that this should be a piece of cake. Below small code snippet showing how to send message using library Apache Commons Net.

public class Main {

 public static void main(String[] args) throws Exception {

 NNTPClient client = new NNTPClient();
 client.connect("news.ustronie.pw.edu.pl");

 client.selectNewsgroup("pw.test");
 Writer postArticle = client.postArticle();

 SimpleNNTPHeader headers =
 new SimpleNNTPHeader("Tomasz Dziurko <tdziurko@gmail.com>", "Test kodowania polskich znaków");
 headers.addNewsgroup("pw.test");
 headers.addHeaderField("Mime-Version", "1.0");
 headers.addHeaderField("Content-Type","text/plain; charset=UTF-8");
 headers.addHeaderField("Content-Transfer-Encoding", "8bit");

 postArticle.write(headers.toString());
 postArticle.write("ąęóśłżźćń - test polskich znaków\r\n");
 postArticle.close();

 client.completePendingCommand();

 client.disconnect();
 }

}

Everything worked as expected until I started to use Polish characters in the message. Then instead of “ąęóśłżźćń” I saw following picture:
Invalid characters encoding in NNTP class in Apache Commons Net 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!

My impressions after passing SCJP

Tags: , ,

Info for Polish readers: this post was originally written in Polish and you can read it here with some additional details about taking exam in Prometric center in Poland.

It’s been some time since I passed my Sun Certified Java Programmer (SCJP) version 1.5, but maybe this post will help somebody to choose his way to prepare to this exam and also increase his chances to score better.

Useful stuff

  • SCJP Sun Certified Programmer for Java 5 Study Guide (Exam 310-055), simply “must have” for anyone planning to get his own, shiny SCJP certificate. This book covers everything you may encouter at the exam. I read it once from cover to cover and repeated chapters that contain areas I didn’t fell comfortable (Generics, Threads).
  • exam simulator EnthuWare JQ+, it costs only 25$ or 18$ (discount for students) and I helped me significantly to achieve better result
  • your favorite IDE to test your ideas, doubts and just to play with example questions from book and simulator.
  • Mariusz Lipiński’s blog (beware: it’s in Polish) where author describes his preparations to the exam in form similar to “Two minute drill” from Sierra & Bates book
  • JavaRanch SCJP Forum where you can meet authors of book I mentioned above

General tips

  • If you don’t have experience with using Java language in various projects better do all tests you can get (book, simulator, free test from the Internet) because after doing it your efficiency in finding traps, nuances will increase a lot.
  • Money spent on exam simulator are never wasted money
  • Experiment, play any time when you are unsure whether something works this way or another. Are you wondering what would happen if this question looked a little different? Don’t only think, launch your IDE and check any variation that comes to your mind. My experiments with Netbeans gave me a lot knowledge and confidence that I really understand the topic.
  • Don’t extend your preparations for too long. Pick a date, even in 3-4 months, when you are going to take the exam and consequently try to make it. Having such “deadline” in your head you will be more determined and regular. I have a friend who is studying for SCJP for more over than half a year and his preparations seems to be endless :)

More about other peoples preperations can be found at:

- (in Polish) here

- SCJP Wall of Fame at JavaRanch portal, check links next to the people names

PS: And I got 80% :)


Be Sociable, Share!