我想把原来用jsp实现的注册登陆功能,用个客户端小程序来实现。jsp的功能是验证成功后由jsp向数据库写入一条记录。所以不涉及senssion等问题。
我的想法:我想用客户端来模拟一个http包给原来的jsp服务器,那样的话服务器端就不用改动了。不知是否可行?具体该用如何实现?
希望能给出更好的想法,或者提供较好的实现方法.

解决方案 »

  1.   

    当然还得返回结果,如成功,用户名密码错,用户已在其他地方登陆等,这些都已在jsp中实现了,就想转移一下。望高手指点!!
      

  2.   

    高手帮帮忙阿,我不想用WebBrowser先下载网页在提交,下载网页太慢了,我就想直接给服务器发送一个包含用户名,密码的请求.
      

  3.   

    提交HTTP信息无外乎POST和GET,对待GET还简单,只要加入网页路径的Query参数即可。比如username是用户名,password是密码(都是字段名)。的话,如下就是通过表单的GET方法发出的数据:
    http://url?username=aaa&password=bbb
    使用?开始Query字段,各个Query字段之间使用&分隔。
    但是POST方法我就不会了,比较难,如果服务器端你可以更改的话就方便了,再说只要自己看看对方的提交表单,重新实现一个只有表单的本地网页不也一样么,还更方便呢。
      

  4.   

    e5022(helpid) 
    其实用post,就没有必要用delphi写程序了.
      

  5.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, HttpProt;type
      TForm1 = class(TForm)
        http1: THttpCli;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    const
      crlf:string=chr(13)+chr(10);
    var
      ms,bb:tmemorystream;
      buf:string;
    begin
      ms:=tmemorystream.Create;
      bb:=tmemorystream.Create;
      bb.LoadFromFile('2.jpg');//文件的数据
      bb.Position:=0;
      buf:='--7d332066021a';
      buf:=buf+crlf+'Content-Disposition: form-data; name="name"'+crlf+crlf+' name'+crlf;
      buf:=buf+'--7d332066021a'+crlf;
      buf:=buf+'Content-Disposition: form-data; name="password"'+crlf+crlf+' possword'+crlf;
      buf:=buf+'--7d332066021a'+crlf;
      buf:=buf+'Content-Disposition: form-data; name="FilePath1"; filename="F:\http 上传\2.jpg"'+crlf;
      buf:=buf+'Content-Type: image/pjpeg'+crlf+crlf;
      ms.WriteBuffer(buf[1],length(buf)); //将头部格式写进去
      ms.Position:=ms.Size;
      ms.CopyFrom(bb,bb.Size);//读入JPG文件数据
      buf:=crlf+'--7d332066021a'+crlf;//分割符
      buf:=buf+'--7d332066021a--';//结束符
      ms.Position:=ms.Size;
      ms.WriteBuffer(buf[1],length(buf));
      ms.Position:=0;
     http1.ContentTypePost:='multipart/form-data, boundary=7d332066021a';//指定entype
     http1.URL:='http://mail.digimaple.com:8080/frameserver/servlet/Upload';
     http1.SendStream:=ms;
     http1.Post;
     ms.Free;
     bb.Free;end;end.
    模拟向网站发送一张图片和用户名以及密码
      

  6.   

    to:  ziping(子平) 
    请问哪里有httpport for del7的下载?
      

  7.   

    ziping(子平) :
    请问在那里能下载 httpport for del7?
      

  8.   

    谁知道在delphi中怎样将如下request提交给指定的服务器?嘉定要提交给http://202.204.114.23/longin.jsp,请给源码,验证成功即刻结贴!
    POST /login.jsp HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
    Referer: http://202.204.112.69
    Accept-Language: zh-cn
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
    Host: 202.204.112.69
    Content-Length: 87
    Connection: Keep-Alive
    Cache-Control: no-cache
    Cookie: JSESSIONID=anpN-6Ll8-dc; CNGASSESSION=F4Q3RK9UEDZ6GDXJNZ9Suser=test&pass=test&ip=211.31.171.25&type=1&action=%D6%D0%B6%CF%C1%AC%CD%F8