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.
精彩评论