now, I'm trying to send data to webserver from arduino UNO with Ethernetshield.
when i implement this source code, there is no error. and i can check "connected""post complete" at serial monitor.
but i can't identify receive post at web server.
web server is consist of eclipse, apache tomcat 6.0, oracle.
help me~~
________________________ sketch ____________________________________________
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
byte mac[] = { 0xCC, 0xAC, 0xBE, 0xEF, 0xFE, 0x91 };
IPAddress wserver(128,134,51,11);
IPAddress ip(192,168,0,21);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
EthernetClient client;
void setup()
{
Serial.begin(9600);
while(!Serial) {
;
}
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip, gateway, subnet);
}
delay(1000);
Serial.println("connecting...");
if (client.connect(wserver, 8888)) {
Serial.println("connected");
client.println("POST /SubwayPassenger/SubwayEnvironment HTTP/1.1");
client.println("HOST: 128.134.51.11:8888");
client.println("Content-Type:application/x-www-form-urlencoded");
client.print("Content-Length: ");
String str = "key=value";
client.println(str.length());
client.println();
client.println(str);
Serial.println("post complete");
}
else {
Serial.println("connection failed");
}
}
void loop()
{
}
------------------------------------------------------server post function --------------------------------------
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
response.setCharacterEncoding("euc-kr");
PrintWriter out = response.getWriter();