这是我正在使用的代码.它不是将数据发布到页面,而是像常规文本文件一样下载它.所以,我实际上是返回了html代码并且没有提交表单.
我知道html表单有效.如果我在浏览器中打开它,我可以发布到它,我的数据显示在我的数据库中.我猜我错过了参数或其他东西.
public void testComm ()
{
try
{
URL url;
URLConnection urlConn;
DataOutputStream printout;
DataInputStream input;
url = new URL ("http://mysite.com/myform.html");
// URL connection channel.
urlConn = url.openConnection();
// Let the run-time system (RTS) know that we want input.
urlConn.setDoInput (true);
// Let the RTS know that we want to do output.
urlConn.setDoOutput (true);
// No caching, we want the real thing.
urlConn.setUseCaches (false);
// Specify the content type.
urlConn.setRequestProperty
("Content-Type", "application/x-www-form-urlencoded");
// Send POST output.
printout = new …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用了很棒的OMDb API,我希望能够使用此API搜索剧集信息.
到目前为止,我已经能够搜索电影/剧集,但我找不到搜索特定剧集的方法.(我想我可以使用剧集的IMDB ID来做到这一点,但要发现我需要搜索OMDb,我不知道怎么做)
有谁知道执行此任务的方法?
为现有的GWT项目编写一些额外的类.我需要:
返回的页面是非常简单的HTML,因此解析它应该不是很困难,我只需要先获取数据.
我如何用Java做到这一点?我最好看哪些套餐?
我正在尝试将我的Java Applet连接到MySQL数据库.我知道它有效,因为我可以在localhost上连接到它,它可以很好地检索记录列表.但是,当我把它放在互联网上时,它不起作用.
这是我的小程序:http://mystikrpg.com/play
它已签名,但我一直收到以下异常:
SQLException获取原因:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败
成功发送到服务器的最后一个数据包是0毫秒前.驱动程序未收到来自服务器的任何数据包.
怎么会发生这种情况,我该怎么做才能解决这个问题呢?
这是applet的源代码:http://sodan.pastebin.com/jWKTgBSU
我向 AppEngine 服务器发送 POST 请求。HttpServletRequest 说我:
POST /connexionDeconnexion HTTP/1.1
User-Agent: Java/1.6.0_20
Host: localhost:8888
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 25
Run Code Online (Sandbox Code Playgroud)
我已经发送了世界“HelloHelloHelloHelloHello”,根据Content-Length是正确的。但是,我不知道如何恢复它。你能解释一下吗?
当我从JSP发送请求时,我使用此代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method="post" action="http://translate.intelsoft.az" id="tform" name="ftext">
<input class="gogo1" value="a" name="l" id="l1" /> <div class="il">
<p>Rusca</p>
<textarea class="ilkin1" name="t" id="t1" >
???????????????????
???????????????????
???????????????????
???????????????????</textarea>
<div><input class="gogo" type="submit" value="T?rcüm?1" name="b1" /></div></div> </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并且响应是正确的,以便我看到参数的值.但是当我从Java发送时,我没有得到正确的答复.我认为参数没有正确发送.这是我的Java代码:
String urlParameters = "t=???????????????????&l=a";
String request = "http://translate.intelsoft.az";
URL url = null;
try {
url = new URL(request);
} catch (MalformedURLException …Run Code Online (Sandbox Code Playgroud) 在我的项目文件夹中,我们有2个ContextPath/WEB-INF/Classes/*.class名称为App1.class和的java文件App2.class
如果我想运行App1.class,我只需要在浏览器中触发URL.
http://localhost:8080/Mapping/App1
Run Code Online (Sandbox Code Playgroud)
同样,如果要触发App2.class,请使用以下链接
http://localhost:8080/Mapping/App2
Run Code Online (Sandbox Code Playgroud)
我想触发App2的App1,意味着如果触发App1在浏览器对应的URL,这将是触发App2.
我也不想做任何回应.
我怎样才能做到这一点.
谁能帮我.
谢谢.
public static Bitmap getImage(String address) throws Exception {
Bitmap imgmap = null;
InputStream is = null;
URL url = new URL(address);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
try {
conn.setRequestMethod("GET"); >>> here was been excuted,but go to finally block
conn.setConnectTimeout(5000);
is = conn.getInputStream();
byte[] imgbytes = StreamTool.getBytes(is);
imgmap = BitmapFactory.decodeByteArray(imgbytes, 0, imgbytes.length);
} finally {
if (is != null) {
is.close();
}
if (conn != null) {
conn.disconnect();
}
}
return imgmap;
}
Run Code Online (Sandbox Code Playgroud)
在conn.setRequestMethod("GET")被解雇之前,Thorw异常连接已经建立.谁能给我一个解决方案
我想在我的应用程序中使用谷歌搜索(包括获取特定结果的选项,如:'结果仅从最后一天').
我怎样才能做到这一点?