"Head First Servlets & JSP"-Preface

Source: Internet
Author: User

"Head First Servlets & JSP" (Chinese version) Bb,ks & BB, Su Yu, Lin Jian, China Power Press

Data interaction

Web browsers and Web servers: Interact with HTML data through the HTTP protocol.

What exactly is MIME type?

To an HTTP response:
The value of the Content-type (content Type) response header is called the MIME type.
The MIME type tells the browser what type of data to receive so that the browser can know how to display the data.
The MIME type value is related to the value listed in the HTTP request "Accept" header. such as a request and a response header information:

Two things the Web server doesn't do itself
    • Dynamic content
      Web server apps only provide static pages and require "helper" to provide dynamic page content. The servlet is such a "helper Application".
    • Save data
      The user sends the data and needs to be saved to a file or database, for which an application is required, and the Web server is only responsible for locating the application and transmitting the data to it.
The role of JSP

In the first servlet program, the HTML tag is written in Java code and is written as a string, and the quotation marks and other syntax can be a disaster.
So, what if, in turn, Java code is written in HTML? --jsp, will be relatively better. Better yet, in the new JSP specification, the page designer should put as little Java code in the JSP as possible or even put it at all, instead putting some markup--jsp syntax that invokes the specific Java method.

Attachment
    • Points
    • The first servlet program Ch1servlet.java
  1. publicclassCh1ServletextendsHttpServlet{
  2. publicvoid doGet(HttpServletRequest request,
  3. HttpServletResponse response)throwsIOException{
  4. PrintWriterout=response.getWriter();
  5. java.util.Date today =new java.util.Date();
  6. out.println("+
  7. "<body>"+
  8. "

    +

  9. "<br/>"+today+"</body>"+");
  10. }
  11. }

Head First Servlets & JSP-Preface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.