开发者

Equivalent to MFC CInternetSession in Java?

开发者 https://www.devze.com 2022-12-21 14:39 出处:网络
I\'m in the process of migrating some of our old code into Java and have become stumped on connecting to开发者_StackOverflow (what I believe are) MFC ASP ports.

I'm in the process of migrating some of our old code into Java and have become stumped on connecting to开发者_StackOverflow (what I believe are) MFC ASP ports.

In the old code this was done via CInternetSession, but I'm uncertain of what the Java equivalent would be.

As an example, the old code had the following:

CInternetSession sess;
pHttpConnect = sess.GetHttpConnection(m_WwwSite, m_port, m_Logon, m_Password);
... do stuff

Does anyone know what the best-fitting replacement for something like this would be? Looking around so far, it seems like I'd need to use some of the classes in servlet-api.jar, but I'd really appreciate an expert opinion before I start heading down a potentially fruitless avenue.

Thanks.


URLConnection conn = new URL("http://" + m_Logon + ":" + m_Password + "@" + m_WwwSite + ":" + m_port).openConnection();

If you don't want to do the string concatenation, you can use the URI constructor instead, then use toURL(). See URL, URI, and URLConnection.

EDIT: I fixed the missing http.

0

精彩评论

暂无评论...
验证码 换一张
取 消