Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
16.12 A Debugging Web Server
423
Figure 16 26 In Internet Explorer, repeatedly pressing the TAB key cycles the input 
focus among the first, third, and second text fields, in that order (as dictated by 
TABINDEX). In Netscape, the input focus would cycle among the first, second, and 
third fields, in that order (based on the order the elements appear on the page).
16.12 A Debugging Web Server
This section presents a mini  Web server  that is useful when you are trying
to understand the behavior of HTML forms. I used it for many of the exam 
ples earlier in the chapter. It simply reads all the HTTP data sent to it by the
browser, then returns a Web page with those lines embedded within a 
PRE
element. This server is also extremely useful for debugging servlets. When
something goes wrong, the first task is to determine if the problem lies in the
way in which you collect data or the way in which you process it. Starting the
EchoServer
 on, say, port 8088 of your local machine, then changing your
forms to specify 
http://localhost:8088/
 lets you see if the data being col 
lected is in the format you expect.
EchoServer
Listing 16.9 presents the top level server code. You typically run it from the
command line, specifying a port to listen on or accepting the default of 8088.
It then accepts repeated HTTP requests from clients, packaging all HTTP
data sent to it inside a Web page that is returned to the client. In most cases,
the server reads until it gets a blank line, indicating the end of 
GET
, 
HEAD
, or
most other types of HTTP requests. In the case of 
POST
, however, the server
checks the 
Content Length
 request header and reads that many bytes
beyond the blank line. 
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved