Java Blog
This is my blog on java, servlets, JSP and design patterns. This might help you to keep your java knowledge updated and also to prepare for your java interview, sun java certification. Its all there, it is left to you how to use it! I started this blog with a selfish reason, just to keep my java knowledge updated and to keep log of the questions that arise in my mind. Now it has turned out to be a full blown java tutorial site with lots of java interview questions and articles. Good day!
Recent Java Articles:
The root cause of IllegalStateException exception is a java servlet is attempting to write to the output stream (response) after the response has been committed.
It is always better to ensure that no content is added to the response after the forward or redirect is done to avoid IllegalStateException. It can be done by including a [...]
May 19th, 2008
Servlet mapping specifies the web container of which java servlet should be invoked for a url given by client. It maps url patterns to servlets. When there is a request from a client, servlet container decides to which application it should forward to. Then context path of url is matched for mapping servlets.
How is servlet [...]
May 14th, 2008
javax.servlet.GenericServlet
Signature: public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable
GenericServlet defines a generic, protocol-independent servlet.
GenericServlet gives a blueprint and makes writing servlet easier.
GenericServlet provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface.
GenericServlet implements the log method, declared in the ServletContext interface.
To write a generic servlet, [...]
May 14th, 2008
In the java servlet life cycle, the first phase is called ‘Creation and intialization’.
The java servlet container first creates the servlet instance and then executes the init() method. This initialization can be done in three ways. The default way is that, the java servlet is initialized when the servlet is called for the first time. [...]
May 14th, 2008
forward
Control can be forward to resources available within the server from where the call is made. This transfer of control is done by the container internally and browser / client is not involved. This is the major difference between forward and sendRedirect. When the forward is done, the original request and response objects are transfered [...]
May 13th, 2008
There is only one type of JSP comment available by JSP specification.
JSP Syntax:
<%-- comment --%>
This JSP comment tag tells the JSP container to ignore the comment part from compilation. That is, it is not considered for the content parsed for ‘response’.
Example:
<%-- This JSP comment part will not be included in the response object --%>
Important Points:
<!-- [...]
May 13th, 2008
Static Variables or Class Variables
Java instance variables are given separate memory for storage. If there is a need for a variable to be common to all the objects of a single java class, then the static modifier should be used in the variable declaration.
Any java object that belongs to that class can modify its static [...]
May 13th, 2008
A static java inner class cannot have instances. A non-static java inner class can have instances that belong to the outer class.
May 12th, 2008
Yes. A java private member cannot be inherited as it is available only to the declared java class. Since the private members cannot be inherited, there is no place for discussion on java runtime overloading or java overriding (polymorphism) features.
May 11th, 2008
JSP Implicit objects are created by the web container. These implicit objects are Java objects that implement interfaces in the Servlet and JSP API. Scripting elements in a JSP page can make use of these JSP implicit objects. There are nine (9) JSP implicit objects available.
JSP Implicit Objects are as follows:
request
The JSP implicit request object [...]
May 11th, 2008