In the JSP, we often read the data from the database back to the client, but we often garbled words phenomenon during production, so we can use <% request. The setCharacterEncoding (" utf-8 "); % >This method to ensure the correct Chinese output, below, for example,
we want to catch the form of value or the database data printed before the first <% request. The setCharacterEncoding (" utf-8 "); % >In front of them, and then, the form of submission must be post, namely the method="post", so that we can avoid garbled the closed, please see the following:

<% request. The setCharacterEncoding (" utf-8 "); % >
<The form action="" method=" post ">
name: <Input type="text" name="name"/>
<Input type="text" name="sex"/>
String name=requset. GetParameter (" name ");
String sex=request. The getParameter (" sex "); Out. Print (name);
out. Print (sex);
% >

or sometimes the user login, we need to be used on a page the user name or password, we can use this method to keep in mind that in the other pages can literally call, such as:

<The form action="" method=" post ">
username: <Input type="text" name="name"/>
password: <Input type="password" name="password"/>
<The form/>
String name=requset. GetParameter (" name ");
String password=request. The getParameter (" password ");
application. SetAttribute (" names ", name);
application. SetAttribute (" passwords, password); Your user name and password have be remembered in this way, the other can literally call, the following
application. The getAttribute (" names ");
application. The getAttribute (" passwords ");
out. The print "names" (application. The getAttribute ());
out. Print (application. The getAttribute (" passwords ")
% >

this will output the value of the text box

you might be interested in the article:

  • JSP values of local non garbled testing machine garbled words problem solving

This concludes the body part