JAVAWEB-PART2---SERVLET/WEB Project structure/Coding Trilogy

Source: Internet
Author: User

Serverlet is the class in Java that handles user requests, and when the browser requests it,
Find Serverlet by matching rules. Call the service method to process the request
<servlet-name>fuhao</servlet-name>//the corresponding name
<servlet-class>com.rupeng.test1.demo4servlet</servlet-class>//the corresponding class file
<servlet-name>fuhao</servlet-name>//the corresponding name
<url-pattern>/fuhao</url-pattern>//the path name following the virtual path

Project structure
Webroot can be accessed directly from the sub-files.
In addition to Meta-inf Web-inf two sub-folders, visitors cannot get directly
Third-party jar packages are placed in the Lib folder under Web-inf

(The project name is a virtual path.) Webroot is the root directory/representative.
Images folder under Webroot is localhost: port number/project name/images)

<form action= "" >/action is the path name of the URL in the XML
Form labels and <input type= "submit"/> are used in conjunction with
Submit a label with the name attribute in all form tags.
Commit to the server in such a way as name= "value".
CheckBox checked the value is on unchecked or null
input/select/textarea/such as the default has the name of the label can be filled out is can be submitted.
The value of the tag corresponding to the submitted label.
<input type= "Submit" name= "A1" value= "A1"/> at the same time a few submit
is to click on the value of the submit and his corresponding name=value.
<input type= "RadioButton" name= "value=" "> When name is the same as RadioButton
Only the selected RadioButton will be submitted to the server.

URL encoding
JavaScript with
Ecodeuri to encode the entire URL
Ecodeuricomponent encodes the value of a name=value that has a function in the URL.
Decode is decoding

Coded in Java using Urlencoder.encode (str, "uft-8")
Urldecoder.decode (str, "Utf-8") decoding

About the encoding format for Chinese.
Develop good habits, use utf-8 (or other) format to set the encoding format uniformly
(HttpServletRequest req, HttpServletResponse resp)
String str=req.getparameter ("Wangzhan");
byte [] bytes= str.getbytes ("iso-8859-1");
String utf8str=new string (bytes, "UTF-8");

Show Trilogy
Resp.setcontenttype ("text/html;charset=uft-8");
Resp.setcharacterencoding ("UTF-8");
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">

Resp.setcontenttype ("text/html")/text/plain. Specifies in what format to output.
is text content or other format

JAVAWEB-PART2---SERVLET/WEB Project structure/Coding Trilogy

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: 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.