Gets the value in the textarea in the JSP

Source: Internet
Author: User

1. Write this most people will, get the value, but get the time will appear we do not want to see the garbled problem

Writing this today is to solve the garbled problem. Here is a small example to explain

2.

(1) First write a JSP page to receive input from the front page

1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"2 pageencoding="UTF-8"%>3 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">4 <HTML>5 <Head>6 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">7 <title>Insert Title here</title>8 </Head>9 <Body>Ten     <formAction= "view.jsp"Method= "POST"> One         <textarearows= "Ten"cols= "+"name= "Content"></textarea> A         <inputtype= "Submit"value= "Submit"/> -     </form> - </Body> the </HTML>
input.jsp

(2) Write a second JSP page to display

1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"2 pageencoding="UTF-8"%>3 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">4 <HTML>5 <Head>6 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">7 <title>Insert Title here</title>8 </Head>9 <Body>Ten     <% One request.setcharacterencoding ("UTF-8"); A         Stringcontent=Request.getparameter ("content"); - out.println (content); -     %> the </Body> - </HTML>
view.jsp

3.

Why is this, because when the Web front-end browser commits, the encoding must be fixed only

4. Result diagram

Input diagram

Result diagram

OK, the validation is complete.

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.