Hi all, I have this method in my servlet
Java Code:
public InputStream getStudentInfo(String studentId) throws Exception {
        URL url = new URL(WS_SERVER_URL + WS_SERVICE_PATH + WS_PARAM + URLEncoder.encode(studentId, "UTF-8"));
        HttpURLConnection connection = (HttpURLConnection)url.openConnection();
        connection.setConnectTimeout(5000);
        connection.setRequestMethod("GET");
        connection.setInstanceFollowRedirects(false);
        connection.setUseCaches(false);
        connection.setDoOutput(true);
        connection.setDoInput(true);

        connection.connect();
        
        int responseCode = connection.getResponseCode();
        
        InputStream result;
        if (responseCode == 200) {
            result = connection.getInputStream();
		} else {
		    throw new Exception("The error occurs while downloading data. (" + connection.getResponseCode() + " " + connection.getResponseMessage() + ")");
		}
		
		return result;
	}
and if I access the servlet in web browser, I get following exception
Java Code:
exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.OutOfMemoryError: unable to create new native thread
	java.lang.Thread.start0(Native Method)
	java.lang.Thread.start(Thread.java:597)
	com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:902)
	com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
	com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1139)
	com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)
	sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:418)
	sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
	sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:133)
	studentInfo.RestClient.getStudentInfo(RestClient.java:41)
	studentInfo.Student.getInfoFromStag(Student.java:24)
	test.TestPage.doPost(TestPage.java:54)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
and this item causes the exception
Java Code:
studentInfo.RestClient.getStudentInfo(RestClient.java:41)
and on this line inside my method lies following code
Java Code:
connection.connect();
Help me, how can I solve it, please.