JSP中的fsockopen等价物 [英] fsockopen equivalent in JSP

查看:110
本文介绍了JSP中的fsockopen等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将此代码转换为JSP

How do i go about converting this code to JSP

任何帮助表示赞赏..!

Any help appreciated..!

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}


推荐答案

您可以使用JSTL标记库为了这。首先在jsp顶部使用

You can use the JSTL taglib for this. First declare the namespace at the top of the jsp using

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

然后使用c:import标签包含来自指定网址的内容:

And then use the c:import tag to include content from the specified url:

<c:import url="htp://www.example.com/" />

这篇关于JSP中的fsockopen等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆