有实例么
特别是和Servlet通信的部分
分值不够可追加

解决方案 »

  1.   

    Servlet是服务器端的Java代码,用于响应客户机的请求。
    一般情况下,请求是由Web浏览器产生的,但其他客户机如Java应用客户机和VC客户机也可以产生请求信息。
    那位大侠了解其工作方法吗
    最好有实例配合
      

  2.   

    一般的http请求就是GET/POST
    BOOL GetInternetFile (LPTSTR lpszServer)
    {
    //Example: Now let's see how to use all these functions in our example.
    //This example shows how to download contents of a page using HTTP API functions.
    HINTERNET hINet, hConnection, hData;
    CHAR buffer[2048] ;
    CString m_strContents ;
    DWORD dwRead, dwFlags, dwStatus ; hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); if ( !hINet )
    {
    AfxMessageBox("InternetOpen Failed");
    return;
    } try
    {
    hConnection = InternetConnect( hINet, "www.mindcracker.com", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
    if ( !hConnection )
    {
    InternetCloseHandle(hINet);
    return;
    }
    // Get data
    hData = HttpOpenRequest( hConnection, "GET", "/uicsa/index.htm", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 ); if ( !hData )
    {
    InternetCloseHandle(hConnection);
    InternetCloseHandle(hINet);
    return;
    }
    HttpSendRequest( hData, NULL, 0, NULL, 0);
    while( InternetReadFile( hData, buffer, 255, &dwRead ) )
    {
    if ( dwRead == 0 )
    return;
    buffer[dwRead] = 0;
    m_strContents += buffer;
    } }
    catch( CInternetException* e)
    {
    e->ReportError();
    e->Delete();
    }
    InternetCloseHandle(hConnection);
    InternetCloseHandle(hINet);
    InternetCloseHandle(hData);
    return bReturn;
    }
      

  3.   

    void post()
    {
        CInternetSession session("My Session");
        CHttpConnection* pServer = NULL;
        CHttpFile* pFile = NULL;
        CString ServerName = "webmail.21cn.com";
        INTERNET_PORT nPort = 80;
        DWORD retcode;
        char outBuff[300] = "LoginName=aaa&passwd=xxx&DomainName=21cn.com";//I have test this with my loginname and password
        try
        {
            pServer = session.GetHttpConnection(ServerName,nPort);
            pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,"/NULL/NULL/NULL/NULL/NULL/SignIn.gen",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);
            // you can read from the file after this......I've just left it out.
            for(int i=0;i<10;i++)//read ten line of returned HTML,you need to edit this to use the result
            {
            CString smsg;
            pFile->ReadString(smsg);
            AfxMessageBox(smsg);
            }
    DWORD dwlen=pFile->GetLength();
    char buf[1024];
    DWORD dwread=pFile->Read(buf,1024);
        }
        catch (CInternetException * e){};
        delete pFile;
        delete pServer;
        session.Close();
    }
      

  4.   

    AddRequestHeaders()
    这里面的参数是怎么确定的?
    有多大关系?不吝赐教
      

  5.   

    为什么不能直接用ActiveX控件实现需要的功能?非要模仿java applet?
      

  6.   

    不能用ActiveX啦
    必须采用模仿java applet的方式
      

  7.   

    服务端是别人做的JAVA我做客户端用VC一样只要遵守TCP/IP协议就OK了,和语言无关
      

  8.   

    代替Applet自然就没问题了,可以这么认为么