Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I access another HTTP server with standard Java APIs?

APIs http Java server standard
0
Posted

How can I access another HTTP server with standard Java APIs?

0

You can use the standard Java APIs to access another HTTP server. It will typically look like this: URL url = new URL(“http://someotherserver”); HttpURLConnection conn = (HttpURLConection) url.openConnection(); conn.connect(); InputStreamReader isr = new InputStreamReader(c.getInputStream()); BufferedReader br = new BufferedReader(isr); String s; while ((s = br.readLine()) != null) { // Do something with the response } br.close(); conn.disconnect(); There is also the forward/include functionality in servlets and JSP that might be useful in certain situations.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123