SoFunction
Updated on 2025-04-07

Functions and parameters in JSP

Functions and parameters of () in JSP

The function of (MIME) is to enable the client browser to distinguish different types of data, and to call different program embed modules in the browser according to different MIMEs to process the corresponding data.

For example, web browsers use MIME type to determine whether a file is a GIF picture. Handle json strings by MIME type.

A large number of MIME types are defined in Tomcat's installation directory \conf\, which can be used as a reference.

("text/html; charset=utf-8"); html
.setContentType("text/plain; charset=utf-8"); text
text/javascript jsondata
application/xml xmldata

This method sets the content type of the response sent to the client, and the response has not been submitted yet. The given content type can include character encoding descriptions, for example: text/html;charset=UTF-8. If the method is called before the getWriter() method is called, the character encoding of the response will be set only from the given content type. If this method is called after the getWriter() method is called or after it is submitted, the character encoding of the response will not be set. In the case of using the http protocol, this method sets the Content-type entity header.

Generally, in Servlets, the content type and encoding method of the request and response are set in habit:

("text/html;charset=UTF-8");
("UTF-8");

String parameters and corresponding types of ()

<option  value="image/bmp">BMP</option>  
<option  value="image/gif">GIF</option>  
<option  value="image/jpeg">JPEG</option>  
<option  value="image/tiff">TIFF</option>  
<option  value="image/x-dcx">DCX</option>  
<option  value="image/x-pcx">PCX</option>  
<option  value="text/html">HTML</option>  
<option  value="text/plain">TXT</option>  
<option  value="text/xml">XML</option>  
<option  value="application/afp">AFP</option>  
<option  value="application/pdf">PDF</option>  
<option  value="application/rtf">RTF</option>  
<option  value="application/msword">MSWORD</option>  
<option  value="application/-excel">MSEXCEL</option>  
<option  value="application/-powerpoint">MSPOWERPOINT</option>  
<option  value="application/wordperfect5.1">WORDPERFECT</option>  
<option  value="application/-wordpro">WORDPRO</option>  
<option  value="application/">VISIO</option>  
<option  value="application/">FRAMEMAKER</option>  
<option  value="application/-1-2-3">LOTUS123</option>

The MIME mapping strategy is which application (i.e., plug-in) is used in a web page and which file to open. There are also issues with usage permissions. For example, for PDF documents, use the "application/pdf" policy. This is common in dynamic web pages. There are two situations for this phenomenon: one is to use an application to open a document that cannot be opened. For example, if you use "DWG" document to define "application/pdf" in a tag, the problem of being unable to be opened will occur. Second, the file extension meets the requirements, but the file content (format) does not meet the requirements. You can check the source code of the web page you browse to get error information. The check method is: view—source file. Look for a string similar to "application/pdf" and you can see if the file to be opened matches the application. Ask if not matched How to solve the answer This is usually changed by the web writer. For example: you find the HTML tag of the file you want to open in the source file and add the application to it. For example, you need to open a PDF document on the web page, find the line of the PDF document, and add type="application/pdf" to the HTML tag. For example, the following HTML file: <!--------------------><html> <head><title>Test MIME</title></head><body> <a type="application/pdf" href="" rel="external nofollow" >Test MIME</a> </body> </html Save the above code as, and then store a pdf document in the same place. Double-click it to open the document in the web page.

If you have any questions, please leave a message or go to the community of this site to exchange and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!