[英]Calling a URL from Java Servlet
I have a PHP URL that inserts a record into a CRM system. 我有一个将记录插入CRM系统的PHP URL。 I need in my servlet to execute this URL - as if I was redirecting to the page (I don't really want to redirect to the page) 我需要在servlet中执行此URL-就像我要重定向到页面一样(我真的不想重定向到页面)
I have code that connects to the URL and reads the content of the page but what I want is just to "Execute" the URL . 我有连接到URL并读取页面内容的代码,但我想要的只是“执行” URL。
What am I missing? 我想念什么?
Thanks. 谢谢。
URL myURL = new URL("http://mydomain.com/test.jsp?myparam=bb");
URLConnection myURLConnection = myURL.openConnection();
myURLConnection.connect();
BufferedReader in = new BufferedReader(new
InputStreamReader(myURLConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
You can try JSoup 您可以尝试JSoup
String url = "http://mydomain.com/test.jsp?myparam=bb"";
Document doc = null;
try {
doc = Jsoup.connect(url).get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
You could use the commons net library. 您可以使用commons网络库。 Here's the home tutorial: http://hc.apache.org/httpclient-3.x/tutorial.html 这是家庭教程: http : //hc.apache.org/httpclient-3.x/tutorial.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.