import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javaQuery.importClass.javaQueryBundle;
import javaQuery.j2ee.GeoLocation;
/**
* Servlet implementation class IP
*/
public class IP extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public IP() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String ipAddress = request.getRemoteAddr();
System.out.println(ipAddress);
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
//Print out the IP address of the caller
out.println(request.getRemoteAddr());
GeoLocation $gl = javaQueryBundle.createGeoLocation();
System.out.println(ipAddress);
$gl.MAPTargetByIP(ipAddress, "test");
System.out.println($gl.Latitude);
System.out.println($gl.Longitude);
System.out.println($gl.Country);
System.out.println($gl.City);
System.out.println($gl.State);
System.out.println($gl.GoogleMap_URL);
System.out.println($gl.GoogleMap_URL_Bubble);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}
这是我的代码片段。我得到的是访客的IP地址,但不是位置信息。它给出:java.net.SocketException:连接重置在java.net.SocketInputStream.Read(未知源)在java.net.SocketInputStream.Read(未知源)
要告诉java代码所有HTTP请求都应该通过代理路由,请使用以下代码段:
System.SetProperty(“http.ProxyHost”,“ProxyHost”);System.SetProperty(“http.ProxyPort”,“ProxyPort”);Authenticator Authenticator=new Authenticator(){public PasswordAuthentication getPasswordAuthentication(){return(new PasswordAuthentication(“username”,“password”.toCharArray()));}};authenticator.SetDefault(authenticator);
System.SetProperty设置代理主机和端口。身份验证器应该是您的公司用户名和密码。现在应该管用了。
问题内容: 我正在尝试使用Java获取我的Internet IP地址,但是当我的IP地址为192.168.0.xxx时,我一直在获取本地地址(即:127.0.0.1) 我正在使用该行: 这似乎是获取IP地址的标准方法,但这不是我想要的。每个教程都说要使用此行,所以我有些困惑。 有人可以让我知道如何获取正确的IP地址吗? 我在连接到WiFi的设备上运行,但未使用任何电缆。我正在使用ifconfig
问题内容: 我在尝试从套接字读取时遇到以下错误。我正在执行该操作,并且出现此错误。仔细阅读文档,这表明连接的客户端部分关闭了连接。在这种情况下,我是服务器。 我可以访问客户端日志文件,但它没有关闭连接,实际上它的日志文件表明我正在关闭连接。有人知道为什么会这样吗?还有什么要检查的?当有本地资源可能达到阈值时,会出现这种情况吗? 我确实注意到我有以下几行: 就在readInt()。这是有原因的(长话
我试图创建一个注册模型,并将其发送到我的API,但位置键有另一个地图/json对象,其中包含类型:点和坐标:[双,双]。 最后一个json对象应该是这样的 我得到的错误是:未处理的异常:类型“\u InternalLinkedHashMap”
问题内容: 我们在日志中看到频繁但间歇的 错误。我们不确定错误的真正来源以及调试方法。 该问题似乎与我们尝试发送的消息无关。请注意,该消息不是 。 关于此异常的典型原因是什么以及如何进行的任何建议? 这是一个代表性的堆栈跟踪(是我们的组件): 我们的组件是一个在Tomcat下运行的Web应用程序,该应用程序调用发送SMS消息的第三方Web服务,这种情况经常发生。引发异常的代码行是下面的代码片段的最
问题内容: 我正在获取一个文本文件并填充一个arraylist。为了测试文件,我在继续之前将其打印出来。我只能从文件中看到内存地址,而不能看到实际信息。有什么简单的东西,也许很明显我想念吗? 测试员 问题答案: 有什么简单的东西,也许很明显我想念吗? 是的- 你没有覆盖的,所以你得到的默认实现: Object类的toString方法返回一个字符串,该字符串包括该对象是其实例的类的名称,符号字符“
Since 10.0.18 getCurrentLocation 新接口 getCurrentLocation 获取当前设备所在的地理位置信息,包括经纬度、准确度、逆地理编码、POI地址等,与此前 getLocation 老接口的参数和错误码定义 不 兼 容 ! 使用方法 AlipayJSBridge.call('getCurrentLocation', { cacheTimeout, req