+ -
当前位置:首页 → 问答吧 → 谁能帮我把这一段ASP代码翻译成JSP代码

谁能帮我把这一段ASP代码翻译成JSP代码

时间:2011-11-01

来源:互联网

谁能帮我把这一段ASP代码翻译成JSP代码?
HTML code
IP为传值,如 "文件名.asp?Ip=202.102.134.68"
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
    dim body,string_start,string_end,Ip
    Ip=request("Ip")
    if Ip="" then Ip="202.102.134.68"
    body=GetPage("http://www.ip138.com/ips.asp?ip="&IP)
    if instr(body,"<li>本站主数据:")>0 then
        body=Getmod(body,"<li>本站主数据:","</li>")
        response.Write("IP:"& IP & " 来自:" &body)
    else
        response.Write("IP错误或者没有数据")
    end if

    Function GetPage(url) 
        dim Retrieval
        Set Retrieval = CreateObject("Microso"&"ft.XM"&"LH"&"TTP") 
        With Retrieval 
        .Open "Get", url, False ', "", "" 
        .Send 
        GetPage = BytesToBstr(.ResponseBody)
        End With 
        Set Retrieval = Nothing 
    End Function

    Function BytesToBstr(body)
        dim objstream
        set objstream = Server.CreateObject("ado"&"db.str"&"eam")
        objstream.Type = 1
        objstream.Mode =3
        objstream.Open
        objstream.Write body
        objstream.Position = 0
        objstream.Type = 2
        objstream.Charset = "GB2312"
        BytesToBstr = objstream.ReadText 
        objstream.Close
        set objstream = nothing
    End Function
    
    Function Getmod(str, kaishi, jieshu)
        'On Error GoTo g
        Dim aa, bb, cc
        aa = InStr(str, kaishi)
        bb = Mid(str, aa, Len(str) - aa)
        cc = Mid(str, aa + Len(kaishi), InStr(bb, jieshu) - Len(kaishi))
        Getmod = Mid(str, aa + Len(kaishi), InStr(bb, jieshu) - Len(kaishi) - 1)
     end Function
%>

</body>
</html>


就是想向IP138传入一个IP值,能将IP138查询到的此IP所属的区域在我的页面上显示出来

作者: joanagle   发布时间: 2011-11-01

高手来救救场

作者: joanagle   发布时间: 2011-11-01

5555,没有人来呀?

作者: joanagle   发布时间: 2011-11-01