"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
publicclassCh1ServletextendsHttpServlet{
publicvoid doGet(HttpServletRequest request,
HttpServletResponse response)throwsIOException{
PrintWriterout=response.getWriter();
java.util.Date today =new java.util.Date();
out.println("+
"<body>"+
"
+
"<br/>"+today+"</body>"+");
}
}
Head First Servlets & JSP-Preface