Write an HTML form submission and accept data information (get the content that the user submits through the form)

Source: Internet
Author: User
Tags html form

Myinfoform.javapackage Com.fxl;import Java.io.ioexception;import Java.io.printwriter;import Javax.servlet.servletexception;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;public class MyInfoForm Extends HttpServlet {public void doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {response.setcontenttype ("text/html;charset=utf-8"); PrintWriter out = Response.getwriter (); Out.println ("");} public void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { This.doget (request, Response);}} Accept form submission Information Registercl.javapackage Com.fxl;import Java.io.ioexception;import java.io.printwriter;import Javax.servlet.servletexception;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;public class RegisterCl Extends HttpServlet {public void doget (httpservletreQuest request, HttpServletResponse response) throws Servletexception, IOException {response.setcontenttype ("text/html ; Charset=utf-8 "); Request.setcharacterencoding (" Utf-8 "); PrintWriter out = Response.getwriter (); String U=request.getparameter ("username"); String p=request.getparameter ("pwd"); String sex=request.getparameter ("sex");//If you accept the contents of the check box, use getparametervaluesstring [] hobbies= Request.getparametervalues ("hobby"); String city=request.getparameter ("City"); String intro=request.getparameter ("Intro"); String hidden1=request.getparameter ("Hidden1"); Out.println ("User name =" +u+ "
"); Out.println (" Password = "+p+"
"); Out.println (" Gender = "+sex+"
"), if (Hobbies!=null) {for (int i=0;i <>
City: "+city"); Out.println ("
Personal introduction: "+intro"); Out.println ("
Hide the data passed by the control: "+hidden1);} public void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { This.doget (request, Response);}}

Write an HTML form submission and accept data information (get the content that the user submits through the form)

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.