By: aathishankaran Printer Friendly Format
An HTML document is structured as follows:
You might be tempted to omit part of this structure, especially the
noting that virtually major browsers ignore it, even though the HTML 3.2 and 4.0
specifications require it.
This is the version for the Java Web Server.
See http://www.coreservlets.com/ for other versions.
-d C:\JavaWebServer2.0\servlets %1%
I strongly discourage this practice. The advantage of the DOCTYPE
is that it tells HTML valuators which version of HTML you are using, so they
know which specification to check your document against. These valuators are
very valuable debugging services, helping you catch HTML syntax errors that your
browser guesses well on, but that other browsers will have trouble displaying.
The two most popular on-line valuators are the ones from the World Wide Web
and from the Web Design Group (http://www.htmlhelp.com/tools/validator/).
They let you submit a URL, and then they retrieve the page, check the syntax
against the formal HTML specification, and report any errors to you. Since a
servlet that generates HTML looks like a regular Web page to visitors, it can be
validated in the normal manner unless it requires POST data to return its result. Remember that GET
is attached to the URL, so you can submit a URL that includes GET
to the valuators.
Admittedly it is a bit cumbersome to generate HTML with println
especially long tedious lines like the DOCTYPE declaration. Some people address this
problem by writing detailed HTML generation utilities in Java, and then use them
throughout their servlets. I’m skeptical of the utility of an extensive
library for this. First and foremost, the inconvenience of generating HTML
programmatically is one of the main problems addressed by Java Server Pages
(discussed in the second part of this book). JSP is a better solution, so
don’t waste effort building a complex HTML generation package.
Second, HTML generation routines can be cumbersome and tend not to
handlers, table cell background colors, and so forth). Despite the questionable
value of a full-blown HTML generation library, if you find you’re repeating
the same constructs many times, you might as well create a simple utility file
that simplifies those constructs. For standard servlets, there are two parts of
the Web page (DOCTYPE
that are unlikely to change and thus could benefit from being incorporated into
a simple utility file.
Most Viewed Articles (in JSP )
Latest Articles (in JSP)
Comment on this tutorial
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews
Subscribe to Tutorials
View Tutorial By: granite falls casino hours hobbs at 2017-08-07 03:47:04