java servlet programming 1998

409 305 0
java servlet programming 1998

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... classes in the javax .servlet. http package to add HTTP-specific functionality The top-level package name is javax instead of the familiar java, to indicate that the Servlet API is a standard extension Every servlet must implement the javax .servlet. Servlet interface Most servlets implement it by extending one of two special classes: javax .servlet. GenericServlet or javax .servlet. http.HttpServlet A protocol-independent... the server The Servlet API Now that you have a basic understanding of HTTP, we can move on and talk about the Servlet API that you'll be using to create HTTP servlets, or any kind of servlets, for that matter Servlets use classes and interfaces from two packages: javax .servlet and javax .servlet. http The javax .servlet package contains classes to support generic, protocol-independent servlets These classes... portability Servlets are supported on all platforms that support Java, and servlets work with all the major web servers.∗ Java servlets, as defined by the Java Software division of Sun Microsystems (formerly known as JavaSoft), are the first standard extension to Java This means that servlets are officially blessed by Sun and are part of the Java language, but they are not part of the core Java API Therefore,... any Java Virtual Machine (JVM), servlet classes need not be bundled with all JVMs More information about the Java Extension Framework is available at http/ /java. sun.com/products/jdk/1.2/docs/guide/extensions To make it easy for you to develop servlets, Sun has made publicly available a set of classes that provide basic servlet support The javax .servlet and javax .servlet. http packages constitute this Servlet. .. The remainder in the javax .servlet and javax .servlet. http packages are largely support classes For example, the ServletRequest and ServletResponse classes in javax .servlet provide access to generic server requests and responses, while HttpServletRequest and HttpServletResponse in javax .servlet. http provide access to HTTP requests and responses The javax .servlet. http package also contains an HttpSession... To keep things as simple as possible, this servlet just says ''Hello World" every time it is accessed via a web browser.∗ Example 2-1 A servlet that prints "Hello World" import java. io.*; import javax .servlet. *; import javax .servlet. http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType... implement this strategy (more properly called a hack) in our Hello servlet Example 2-3 The Hello servlet modified to return quickly in response to HEAD requests import java. io.*; import javax .servlet. *; import javax .servlet. http.*; public class Hello extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // Set the Content-Type header... VALUE=EST> < /SERVLET> The servlet named CurrentTime can be plugged into any page that needs a time display The name can be either the servlet' s class name or its registered name The servlet code is shown in Example 2-4 Example 2-4 A server-side include that prints the current time import import import import import java. io.*; java. text.*; java. util.*; javax .servlet. *; javax .servlet. http.*;... performance Support for server-side JavaScript is available only with Netscape FastTrack Server and Enterprise Server Version 2.0 and above For more information on programming with server-side JavaScript, see http://developer.netscape.com/tech/javascript/ssjs/ssjs.html Java Servlets Enter Java servlets As was said earlier, a servlet is a generic server extension—a Java class that can be loaded dynamically... request object to read the "name" parameter Example 2-2 A servlet that knows to whom it's saying hello import java. io.*; import javax .servlet. *; import javax .servlet. http.*; public class Hello extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType(“text/html”); PrintWriter out = res.getWriter(); String name . w0 h0" alt="" Java Servlet Programming Exploring Java Java Threads Java Network Programming Java Virtual Machine Java AWT Reference Java Language Reference Java Fundamental Classes. Reference Database Programming with JDBC and Java Java Distributed Computing Developing Java Beans Java Security Java Cryptography Java Swing Java Servlet Programming Also from O'Reilly Java . O'Reilly Java in a Nutshell Java in a Nutshell, Deluxe Edition Java Examples in a Nutshell Java Servlet Programming Jason Hunter with William Crawford Java  Servlet Programming by Jason Hunter

Ngày đăng: 19/04/2014, 18:00

Mục lục

    2 - HTTP Servlet Basics

    3 - The Servlet Life Cycle

    5 - Sending HTML Information

    6 - Sending Multimedia Content

    13 - Odds and Ends

    A - Servlet API Quick Reference

    B - HTTP Servlet API Quick Reference

    C - HTTP Status Codes

    D - Character Entities

Tài liệu cùng người dùng

Tài liệu liên quan