specify the order in which we want to initialize various Servlets. Like first initialize Servlet1 then Servlet2 and so on. This is accomplished by specifying a numeric value for the <load-on-startup> tag. <load-on-startup> tag specifies that the servlet should be loaded automatically when the web application is started. The value is a single positive integer, [...]
Archive | Servlets RSS feed for this section
ServletContextListener Example
February 26, 2009
This tips explains the how to use ServletContextListener. There will be only one ServletContext for each web application. ServletContext will be created while deploying the application. Once the ServletContext is created, it will be used by all the servlets and jsp files in the same application. ServletContext is also called as the application scope variables [...]
load-on-startup element in web.xml
February 17, 2009
This tips explains the few points on how to use the load-on-startup element on the web.xml file. When erver is starting, it is possible to tell the container to load a servlet on the startup. You can load any number of servlets on the startup. Normally this is done for any initialization purpose. Look into [...]
Servlets Interview Questions
February 13, 2009
1) Is it the “servlets” directory or the “servlet” directory? For Java Web Server: on the file system, it’s “servlets” c:\JavaWebServer1.1\servlets\DateServlet.class in a URL path, it’s “servlet” http://www.stinky.com/servlet/DateServlet 2) How do I support both GET and POST protocol from the same Servlet? The easy way is, just support POST, then have your doGet method call [...]
New Features in Servlets 2.5
January 6, 2009
1.Introduction This article presents new features introduced in the Servlet 2.5. Servlet 2.5 is bundled with Java EE 5.0 edition and it has lot of new features. This version has major changes since it has to support the Java 5.0 version for all the J2EE technologies. One of the notable changes will be supporting Generics [...]
New Features in Servlets 3.0
December 23, 2008
Introduction This article covers most of the important features available as part of Servlet 3.0 specification. Note that the Servlet 3.0 specification constantly keeps changing frequently with the reviews coming in and the features and the API’s mentioned in this article is based on the specification that is available in JCP for public review as [...]
Servlet 3.0
October 2, 2008
Can’t wait to see Servlet 3.0 in action. More details about the specification and the current status is available in its JSR homepage. The introduction of support for non-blocking I/O takes Java Servlets to a new level and this, in my opinion,is the most significant stride in Servlet specification since it was introduced. The benefits [...]
How to delete a cookie on server in a J2EE application
September 25, 2008
There is no direct method offered by servlet API to delete a cookie on server side. This is how you can go about doing it. 1) Loop through the cookies in the request object to locate the one that you want to delete. 1 2 3 4 5 for (Cookie cookie: request.getCookies()) { if (USER_COOKIE_NAME.equals(cookie.getName())) [...]
Servlet Life Cycle
August 1, 2008
Before start writing the servlet, it is important to know the life cylce of every servlet instance created. Read What is Servlet? tips to know about the servlet basics. Servlet Life Cycle Methods The following are the life cycle methods of a servlet instance: init() service() destroy() We will look into the each method in [...]
New Features in Servlet 3.0
July 31, 2008
Servlet 3.0 The next version for servlet technology is Servlet 3.0, which is planned to be released with JEE 6.0 in the last quarter of 2008. After the release of servlet 2.5 in spetember 2005, this is the new version with many new features included. Servlet 2.5 is released with JEE 5.0. Servlet 3.0 is [...]






February 21, 2013
0 Comments