//computer.jsp功能为根据三角形三边求面积
void PostForm()
{
CInternetSession session("My Session");
CHttpConnection *pServer = NULL;
CHttpFile *pFile = NULL;
CString ServerName = "127.0.0.1";
INTERNET_PORT nPort = 8080;
DWORD retcode;
char outBuff[] = "sideA=3&sideB=4&sideC=5";//三角形三边
try
{
pServer = session.GetHttpConnection(ServerName,nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,"computer.jsp",NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
pFile->AddRequestHeaders("Content-Type:application/x-www-form-urlencoded");
pFile->AddRequestHeaders("Accept:*/*");
pFile->SendRequest(NULL,0,outBuff,strlen(outBuff)+1);
pFile->QueryInfoStatusCode(retcode);
DWORD dwlen=pFile->GetLength();
char *buf = new char[dwlen];
DWORD dwread=pFile->Read(buf,1024);
printf("%s
", buf);
delete []buf;
}
catch (CInternetException e)
{
AfxMessageBox("Error Occur!");
}
delete pFile;
delete pServer;
session.Close();
}