[Java] [Web] Request get header and data

Source: Internet
Author: User

Get Way One

InputStream in = Request.getinputstream ();

int len = 0;

byte buffer[] = new byte[1024];

while (len = in.read (buffer)) > 0) {

System.out.println (len);

System.out.println (New String (Buffer,0,len));

}

Get Way Two

String value = Request.getparameter ("username");

if (value! = null &&!value.trim (). Equals ("")) {
System.out.println (value);

}

Get Way Three

Enumeration E = Request.getparameternames ();

while (E.hasmoreelements ()) {

String name = (string) e.nextelement ();

Value = Request.getparameter (name);

SYSTEM.OUT.PRINTLN (name + ":" + value);

}

Get Way Four

String[] values = request.getparametervalues ("username");

for (int i=0;values!=null && i < values.length;i++) {

System.out.println (Values[i]);

}

Get Way Five

Map map = Request.getparametermap ();

User user = new user ();

Beanutils.populate (user, map);

... The Commons-beanutils-1.8.0.jar and Commons-logging.jar packages are quoted here.

public class user{

Public string[] GetUserName () {...}

Public string[] GetPassword () {...}

}

[Java][web]request Get request headers and data

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.