Java
--
Questions
--
Followers
Top Experts
Java HTTP Web Server Post Request
Hi I am triying to develop HTTP web server which will response post request.
I am reading request like tihs.
while (true) {
String misc = br.readLine();
System.out.println("=====> " + misc);
if (misc==null || misc.length()==0)
break;
}
It can print messages from browser.
Like this.
=====> POST /mypage.html HTTP/1.1
=====> Host: 127.0.0.1:8080
=====> Connection: keep-alive
=====> Content-Length: 36
=====> Cache-Control: max-age=0
=====> Origin: http://127.0.0.1:8080
=====> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
=====> Content-Type: application/x-www-form-url encoded
=====> Accept: text/html,application/xhtm l+xml,appl ication/xm l;q=0.9,*/ *;q=0.8
=====> Referer: http://127.0.0.1:8080/mypage4.html
=====> Accept-Encoding: gzip,deflate,sdch
=====> Accept-Language: tr-TR,tr;q=0.8,en-US;q=0.6 ,en;q=0.4
=====> Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q =0.3
But there is no post datas ?
I am lokin for like this.
name=J.Doe&email=abuse%40s pamcop.com
Why i cat get the data ?.
My form code
<form method="post" enctype="application/x-www -form-urle ncoded; charset=UTF-8">
<input name="name" type="text" /><input name="email" type="text" /><input name="Submit1" type="submit" value="gönder" /></form>
Where is the problem.
I am reading request like tihs.
while (true) {
String misc = br.readLine();
System.out.println("=====>
if (misc==null || misc.length()==0)
break;
}
It can print messages from browser.
Like this.
=====> POST /mypage.html HTTP/1.1
=====> Host: 127.0.0.1:8080
=====> Connection: keep-alive
=====> Content-Length: 36
=====> Cache-Control: max-age=0
=====> Origin: http://127.0.0.1:8080
=====> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
=====> Content-Type: application/x-www-form-url
=====> Accept: text/html,application/xhtm
=====> Referer: http://127.0.0.1:8080/mypage4.html
=====> Accept-Encoding: gzip,deflate,sdch
=====> Accept-Language: tr-TR,tr;q=0.8,en-US;q=0.6
=====> Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q
But there is no post datas ?
I am lokin for like this.
name=J.Doe&email=abuse%40s
Why i cat get the data ?.
My form code
<form method="post" enctype="application/x-www
<input name="name" type="text" /><input name="email" type="text" /><input name="Submit1" type="submit" value="gönder" /></form>
Where is the problem.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
A blank line is sent between headers and data. See
http://developers.sun.com/mobility/midp/ttips/HTTPPost/
http://developers.sun.com/mobility/midp/ttips/HTTPPost/
Thanks. How can I read after blank line.
The bufferedReader waiting on the blank line.
I try like this.
but I cant do this.
currentLine = br.readLine();
List.add(currentLine);
StringTokenizer methToken = new StringTokenizer(currentLin e, " ");
Method = methToken.nextToken();
actionPage = methToken.nextToken();
System.out.println("Method Type : " + Method);
System.out.println("Action s Page : " + actionPage);
while (true) {
currentLine = br.readLine();
if (currentLine == null || currentLine.trim().length( ) == 0) {
if (Method.toUpperCase().equa ls("POST") ) {
br.skip(1);
currentLine = br.readLine();
System.out.println("=====> " + currentLine);
List.add(currentLine);
}
else {
break;
}
}
else{
System.out.println("=====> " + currentLine);
List.add(currentLine);
}
}
How can i read after the balnk line ?
The bufferedReader waiting on the blank line.
I try like this.
but I cant do this.
currentLine = br.readLine();
List.add(currentLine);
StringTokenizer methToken = new StringTokenizer(currentLin
Method = methToken.nextToken();
actionPage = methToken.nextToken();
System.out.println("Method
System.out.println("Action
while (true) {
currentLine = br.readLine();
if (currentLine == null || currentLine.trim().length(
if (Method.toUpperCase().equa
br.skip(1);
currentLine = br.readLine();
System.out.println("=====>
List.add(currentLine);
}
else {
break;
}
}
else{
System.out.println("=====>
List.add(currentLine);
}
}
How can i read after the balnk line ?
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
I've requested that this question be closed as follows:
Accepted answer: 0 points for Absente's comment http:/Q_27488267.html#37271819
Assisted answer: 100 points for rrz@871311's comment http:/Q_27488267.html#37269638
Assisted answer: 0 points for Absente's comment http:/Q_27488267.html#37269714
for the following reason:
thanks
Accepted answer: 0 points for Absente's comment http:/Q_27488267.html#37271819
Assisted answer: 100 points for rrz@871311's comment http:/Q_27488267.html#37269638
Assisted answer: 0 points for Absente's comment http:/Q_27488267.html#37269714
for the following reason:
thanks






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I answered the question. I should get the full 500 points.
Java
--
Questions
--
Followers
Top Experts
Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.