Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: The servlet API and NIO: Together at last

The Servlet API and NIO:Together at last Think it\'s impossible to combine NIO and the Servlet API? Think again. In this article, Java developer Taylor Cowan shows you how to apply the producer/consumer model to consumer nonblocking I/O, thus easing the

Tutorial Details:

In this article, you\'ll learn how to work around the Servlet API\'s aversion to nonblocking I/O to create a Servlet-based Web server that implements NIO. We\'ll then see how this server scales against a standard I/O server (Tomcat 5.0) in a multiplexed Web server environment. In keeping with the realities of life in the enterprise, we\'ll focus on how NIO compares to standard I/O when an exponentially increasing number of clients retain their socket connections.
The Servlet API and NIO
Nonblocking reads and writes are essential to NIO, but they don\'t come trouble free. A nonblocking read makes no guarantee to the caller besides the fact that it won\'t block. The client or server application may read the complete message, a partial message, or nothing at all. On the other hand, a nonblocking read might read more than enough, forcing an overhead buffer for the next call. And, finally, unlike streams a zero byte read does not indicate that the message has been fully received.
These factors make it impossible to implement even a simple readline method without polling. All servlet containers must provide a readline method on their input streams. As a result, many developers have given up on building a Servlet-based Web application server that implements NIO. Fortunately, there is a solution; one that combines the power of the Servlet API and the multiplexed I/O of NIO.




 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
The servlet API and NIO: Together at last

View Tutorial:
The servlet API and NIO: Together at last

Related Tutorials:

What's new in Java Servlet API 2.2? - JavaWorld October 1999
What's new in Java Servlet API 2.2? - JavaWorld October 1999
 
Secure a Web application, Java-style - JavaWorld April 2000
Secure a Web application, Java-style - JavaWorld April 2000
 
Take control of the servlet environment, Part 1 - JavaWorld November 2000
Take control of the servlet environment, Part 1 - JavaWorld November 2000
 
Untangle your servlet code with reflection - JavaWorld December 2000
Untangle your servlet code with reflection - JavaWorld December 2000
 
Take control of the servlet environment, Part 2 - JavaWorld December 2000
Take control of the servlet environment, Part 2 - JavaWorld December 2000
 
Servlet 2.3: New features exposed - JavaWorld January 2001
Servlet 2.3: New features exposed - JavaWorld January 2001
 
Take control of the servlet environment, Part 3 - JavaWorld January 2001
Take control of the servlet environment, Part 3 - JavaWorld January 2001
 
Untangle your servlet code with reflection
Untangle your servlet code with reflection
 
Facilitate form
Facilitate form processing with the Form Processing API
 
Transform data into Web applications with Cocoon
Transform data into Web applications with Cocoon
 
Servlet 2.4: What's in store
Servlet 2.4: What's in store
 
Introducing the Portlet Specification, Part 2
Introducing the Portlet Specification, Part 2
 
Isolate server includes' runtime context
Isolate server includes' runtime context
 
good design pattern
good design pattern
 
Accessing Databases Using Java and JDBC
This article will show how a Java Application, Applet or Servlet can access data stored in relational databases using the JDBC API.
 
Internet & Intranets: Java Servlets
What are servlets? "Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to upd
 
Building Java Server Pages
A detailed look at building JSP pages. Should you use JSP or servlets? It mainly depends on the ratio of markup to code. Here you'll also find a guide to the different varieties of tag, and details about the main tags such as and  
Introduction to Servlets, JSP, and Servlet Engines
Servlets are the Java Technologies' answer to CGI programming. They are programs which run on the server side and generate dynamic content. Why would one prefer to use Servlets over traditional CGI programming?
 
First Step towards JDBC!
First Step towards JDBC! Welcome to our JDBC Section First Step towards JDBC This article introduce you with JDBC and shows you how to create a database application to access the databases. Accessing the Database from Servlet This article shows
 
Accessing Database from servlets through JDBC!
Accessing Database from servlets through JDBC! Java Servlets J ava Servlets are server side components that provides a powerful mechanism for developing server side of web application. Earlier CGI was developed to provide server side capabilities
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.