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

joanagle 2011-11-01 11:46:32
谁能帮我把这一段ASP代码翻译成JSP代码?
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所属的区域在我的页面上显示出来
...全文
86 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
joanagle 2011-11-02
  • 打赏
  • 举报
回复
分不够可以再加的
joanagle 2011-11-01
  • 打赏
  • 举报
回复
5555,没有人来呀?
joanagle 2011-11-01
  • 打赏
  • 举报
回复
高手来救救场

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧