Java Code Examples for java.net.HttpURLConnection.HTTP_OK

The following are Jave code examples for showing how to use HTTP_OK of the java.net.HttpURLConnection class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: database-transform-tool   File: HttpUtil.java   Source Code and License Vote up 8 votes
/**
 * @description 判断服务连通性
 * @author yi.zhang
 * @time 2017年4月19日 下午6:00:40
 * @param url
 * @param auth	认证信息(username+":"+password)
 * @return (true:连接成功,false:连接失败)
 */
public static boolean checkConnection(String url,String auth){
	boolean flag = false;
	try {
		HttpURLConnection connection = (HttpURLConnection)new URL(url).openConnection();
		connection.setConnectTimeout(5*1000);
		if(auth!=null&&!"".equals(auth)){
			String authorization = "Basic "+new String(Base64.encodeBase64(auth.getBytes()));
			connection.setRequestProperty("Authorization", authorization);
		}
		connection.connect();
		if(connection.getResponseCode()==HttpURLConnection.HTTP_OK){
			flag = true;
		}
		connection.disconnect();
	}catch (Exception e) {
		logger.error("--Server Connect Error !",e);
	}
	return flag;
}
 
Example 2
Project: opencps-v2   File: PaymentFileManagement.java   Source Code and License Vote up 7 votes
@PUT
@Path("/{id}/payments/{referenceUid}/confirm/noattachment")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@ApiOperation(value = "Update PaymentFile")
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updatePaymentFileConfirmNoAttachment(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, 
		@ApiParam(value = "id of payments", required = true) @PathParam("id") String id,
		@ApiParam(value = "reference of paymentFile", required = true) @PathParam("referenceUid") String referenceUid,
		@BeanParam PaymentFileInputModel input);
 
Example 3
Project: opencps-v2   File: MultipartUtility.java   Source Code and License Vote up 7 votes
/**
 * Completes the request and receives response from the server.
 * 
 * @return a list of Strings as response in case the server returned status
 *         OK, otherwise an exception is thrown.
 * @throws IOException
 */
public List<String> finish() throws IOException {
	List<String> response = new ArrayList<String>();

	writer.append(LINE_FEED).flush();
	writer.append("--" + boundary + "--").append(LINE_FEED);
	writer.close();

	// checks server's status code first
	int status = httpConn.getResponseCode();
	if (status == HttpURLConnection.HTTP_OK) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
		String line = null;
		while ((line = reader.readLine()) != null) {
			response.add(line);
		}
		reader.close();
		httpConn.disconnect();
	} else {
		throw new IOException("Server returned non-OK status: " + status);
	}

	return response;
}
 
Example 4
Project: LoRaWAN-Smart-Parking   File: ResponseHeaders.java   Source Code and License Vote up 6 votes
/**
 * Returns true if this response can be stored to later serve another
 * request.
 */
public boolean isCacheable(RequestHeaders request) {
  // Always go to network for uncacheable response codes (RFC 2616, 13.4),
  // This implementation doesn't support caching partial content.
  int responseCode = headers.getResponseCode();
  if (responseCode != HttpURLConnection.HTTP_OK
      && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE
      && responseCode != HttpURLConnection.HTTP_MULT_CHOICE
      && responseCode != HttpURLConnection.HTTP_MOVED_PERM
      && responseCode != HttpURLConnection.HTTP_GONE) {
    return false;
  }

  // Responses to authorized requests aren't cacheable unless they include
  // a 'public', 'must-revalidate' or 's-maxage' directive.
  if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) {
    return false;
  }

  if (noStore) {
    return false;
  }

  return true;
}
 
Example 5
Project: opencps-v2   File: DeliverablesManagement.java   Source Code and License Vote up 5 votes
@GET
@Path("/deliverables/{id}/update/{deliverableAction}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Update deliverableAction by deliverable id")
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not Found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access defined", response = ExceptionModel.class) })
public Response getDeliverableAction(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@ApiParam(value = "id of Deliverable", required = true) @PathParam("id") Long id,
		@ApiParam(value = "deliverableAction", required = true) @PathParam("deliverableAction") String deliverableAction);
 
Example 6
Project: opencps-v2   File: PaymentFileManagement.java   Source Code and License Vote up 5 votes
@GET
@Path("/paymentfiles")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@ApiOperation(value = "Get info Payment files", response = PaymentFileSearchResultModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Return a list of PaymentFile", response = PaymentFileSearchResultModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "", response = ExceptionModel.class) })
public Response getPaymentFiles(@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@ApiParam(value = "body params of post", required = true) @BeanParam PaymentFileSearchModel search);
 
Example 7
Project: SamaGamesAPI   File: GameProfileBuilder.java   Source Code and License Vote up 5 votes
public static GameProfile fetch(UUID uuid, boolean forceNew) throws IOException
{
    if (!forceNew && cache.containsKey(uuid) && cache.get(uuid).isValid())
    {
        return cache.get(uuid).profile;
    }
    else
    {
        HttpURLConnection connection = (HttpURLConnection) new URL(String.format(SERVICE_URL, UUIDTypeAdapter.fromUUID(uuid))).openConnection();
        connection.setReadTimeout(5000);

        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK)
        {
            InputStreamReader response = new InputStreamReader(connection.getInputStream());
            GameProfile result = gson.fromJson(new BufferedReader(response), GameProfile.class);

            cache.put(uuid, new CachedProfile(result));
            return result;
        }
        else
        {
            if (!forceNew && cache.containsKey(uuid))
            {
                return cache.get(uuid).profile;
            }

            JsonObject error = (JsonObject) new JsonParser().parse(new BufferedReader(new InputStreamReader(connection.getErrorStream())).readLine());
            throw new IOException(error.get("error").getAsString() + ": " + error.get("errorMessage").getAsString());
        }
    }
}
 
Example 8
Project: opencps-v2   File: ServiceProcessManagement.java   Source Code and License Vote up 5 votes
@GET
@Path("/{id}/steps")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get all ProcessSteps of a ServiceProcess", response = ProcessStepResultsModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a list of all ProcessSteps", response = ProcessStepResultsModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response getProcessSteps(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id, @BeanParam ProcessStepSearchModel query);
 
Example 9
Project: opencps-v2   File: ServiceInfoManagement.java   Source Code and License Vote up 5 votes
@GET
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get detail ServiceInfo by code (or Id)", response = ServiceInfoDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the detail of ServiceInfo", response = ServiceInfoDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response getDetailServiceInfo(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id (or code) of ServiceInfo that need to be get detail", required = true) @PathParam("id") String id);
 
Example 10
Project: parabuild-ci   File: PseudoServer.java   Source Code and License Vote up 5 votes
private boolean respondToRequest( HttpRequest request, HttpResponseStream response ) {
    if (_debug) System.out.println( "** Server thread " + hashCode() + " handling request: " + request );
    boolean keepAlive = isKeepAlive( request );
    try {
        response.restart();
        response.setProtocol( getResponseProtocol( request ) );
        WebResource resource = getResource( request );
        if (resource == null) {
            response.setResponse( HttpURLConnection.HTTP_NOT_FOUND, "unable to find " + request.getURI() );
        } else {
            if (resource.closesConnection()) keepAlive = false;
            if (resource.getResponseCode() != HttpURLConnection.HTTP_OK) {
                response.setResponse( resource.getResponseCode(), "" );
            }
            String[] headers = resource.getHeaders();
            for (int i = 0; i < headers.length; i++) {
                if (_debug) System.out.println( "** Server thread " + hashCode() + " sending header: " + headers[i] );
                response.addHeader( headers[i] );
            }
            response.write( resource );
        }
    } catch (UnknownMethodException e) {
        response.setResponse( HttpURLConnection.HTTP_BAD_METHOD, "unsupported method: " + e.getMethod() );
    } catch (Throwable t) {
        t.printStackTrace();
        response.setResponse( HttpURLConnection.HTTP_INTERNAL_ERROR, t.toString() );
    }
    return keepAlive;
}
 
Example 11
Project: opencps-v2   File: DeliverablesManagement.java   Source Code and License Vote up 5 votes
@POST
@Path("/deliverables/agency/{agencyNo}/type/{typeCode}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get list dataform by agencyNo and typeCode")
@ApiResponses(value = {
		@ApiResponse (code = HttpURLConnection.HTTP_OK, message = "Return a list dataform"),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not Found", response = ExceptionModel.class),
		@ApiResponse (code = HttpURLConnection.HTTP_FORBIDDEN, message = "Accsess denied", response = ExceptionModel.class) })
public Response getDataFormByTypeCode (@Context HttpServletRequest request, @Context HttpHeaders header, @Context Company company,
		@Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@ApiParam(value = "id for agency", required = true) @PathParam("agencyNo") String agencyNo,
		@ApiParam(value = "id for type", required = true) @PathParam("typeCode") String typeCode,
		@FormParam("keyword") String keyword);
 
Example 12
Project: opencps-v2   File: DossierManagement.java   Source Code and License Vote up 5 votes
@GET
@Path("/{id}/contacts")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get contacts of Dossier by its id (or referenceId)", response = DossierDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a list of Dossiers have been filtered", response = DossierDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response getContactsDossier(@Context HttpHeaders header, @Context ServiceContext serviceContext,
		@PathParam("id") Long dossierId, @Context String referenceUid);
 
Example 13
Project: opencps-v2   File: DeliverablesManagement.java   Source Code and License Vote up 5 votes
@GET
@Path("/deliverables/{id}/formscript")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get info formscript for deliverable id")
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not Found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access defined", response = ExceptionModel.class) })
public Response getFormScript(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
		@ApiParam(value = "id of Deliverable", required = true) @PathParam("id") Long id);
 
Example 14
Project: opencps-v2   File: ServiceConfigManagement.java   Source Code and License Vote up 5 votes
@GET
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get a ServiceConfig by id", response = ServiceConfigDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a ServiceConfig", response = ServiceConfigDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response getServiceConfig(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "serviceconfigId for get detail") @PathParam("id") long input);
 
Example 15
Project: Android-2017   File: GetAllUsersTask.java   Source Code and License Vote up 4 votes
@Override
protected String doInBackground(String... strings) {

    try {

        URL serviceEndPoint = new URL("http://jsonplaceholder.typicode.com/users/");

        HttpURLConnection connection = (HttpURLConnection) serviceEndPoint.openConnection();

        // timeout de la peticion
        connection.setConnectTimeout(CONNECTION_TIMEOUT);
        connection.setReadTimeout(READ_TIMEOUT);

        // añadimos cabeceras a la conexión
        connection.setRequestProperty("Accept", "application/json");
        // connection.setRequestProperty("Authorization", "Basic lajskjflskjflsfjslfjslflsjfdls");

        // indicamos que tipo de petición vamos a realizar (GET, POST, ....)
        connection.setRequestMethod("GET");

        // se lanza la petición y se mira el resultado
        connection.connect();

        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            // recuperamos un stream con la respuesta del servidor.
            InputStream input = connection.getInputStream();

            BufferedReader reader = new BufferedReader(new InputStreamReader(input));
            StringBuilder result = new StringBuilder();
            String line;

            while ((line = reader.readLine()) != null) {
                result.append(line);
            }

            // Se ha leido la respuesta de manera correcta. retornamos el json como string recibido
            return result.toString();

        }

        else {
            Log.e (TAG, "Error reading response from " + serviceEndPoint.toString() + " with code " + connection.getResponseCode());
        }

    } catch (MalformedURLException mue) {
        Log.e(TAG, "MalformedURLException", mue);

    } catch (IOException ioe) {
        Log.e(TAG, "IOException", ioe);
    }

    return COMUNICATION_ERROR;
}
 
Example 16
Project: lams   File: WebResource.java   Source Code and License Vote up 4 votes
public WebResource( byte[] contents, String contentType ) {
    this( contents, contentType, HttpURLConnection.HTTP_OK );
}
 
Example 17
Project: Nearby   File: ParsePHP.java   Source Code and License Vote up 4 votes
public void run(){

        String response = new String();

        try {
//            Thread.sleep(2000);

            URL url = new URL(urlText);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection(); // 해당 URL에 연결

            conn.setConnectTimeout(10000); // 타임아웃: 10초
            conn.setUseCaches(false); // 캐시 사용 안 함
            conn.setRequestMethod("POST"); // POST로 연결
            conn.setDoInput(true);
            conn.setDoOutput(true);

            if (postData != null) { // 웹 서버로 보낼 매개변수가 있는 경우우
                OutputStream os = conn.getOutputStream(); // 서버로 보내기 위한 출력 스트림
                BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); // UTF-8로 전송
                bw.write(getPostString(postData)); // 매개변수 전송
                bw.flush();
                bw.close();
                os.close();
            }

            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { // 연결에 성공한 경우
                String line;
                BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); // 서버의 응답을 읽기 위한 입력 스트림

                while ((line = br.readLine()) != null) // 서버의 응답을 읽어옴
                    response += line;
            }

            conn.disconnect();
        } catch (MalformedURLException me) {
            me.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

        String str = response.toString();

        Looper.prepare();
        afterThreadFinish(str);

    }
 
Example 18
Project: PRDownloader   File: DownloadTask.java   Source Code and License Vote up 4 votes
private boolean isSuccessful() {
    return responseCode >= HttpURLConnection.HTTP_OK
            && responseCode < HttpURLConnection.HTTP_MULT_CHOICE;
}
 
Example 19
Project: android_nextgis_mobile   File: NetworkUtil.java   Source Code and License Vote up 4 votes
public static String postFile(
        String targetURL,
        String fileName,
        File file,
        String fileMime,
        String username,
        String password)
        throws IOException
{
    final String lineEnd = "\r\n";
    final String twoHyphens = "--";
    final String boundary = "**nextgis**";

    //------------------ CLIENT REQUEST
    FileInputStream fileInputStream = new FileInputStream(file);
    // open a URL connection to the Servlet

    HttpURLConnection conn = getHttpConnection("POST", targetURL, username, password);
    if (null == conn) {
        if (ConstantsUI.DEBUG_MODE) {
            Log.d(ConstantsUI.TAG, "Error get connection object: " + targetURL);
        }
        return "0";
    }
    conn.setRequestProperty("Connection", "Keep-Alive");
    conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
    // Allow Outputs
    conn.setDoOutput(true);

    DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
    dos.writeBytes(twoHyphens + boundary + lineEnd);
    dos.writeBytes(
            "Content-Disposition: form-data; name=\"file\"; filename=\"" + fileName + "\""
                    + lineEnd);

    if (!TextUtils.isEmpty(fileMime)) {
        dos.writeBytes("Content-Type: " + fileMime + lineEnd);
    }

    dos.writeBytes(lineEnd);

    byte[] buffer = new byte[ConstantsUI.IO_BUFFER_SIZE];
    FileUtil.copyStream(fileInputStream, dos, buffer, ConstantsUI.IO_BUFFER_SIZE);

    dos.writeBytes(lineEnd);
    dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
    fileInputStream.close();
    dos.flush();
    dos.close();

    int responseCode = conn.getResponseCode();
    if (responseCode != HttpURLConnection.HTTP_OK) {
        if (ConstantsUI.DEBUG_MODE) {
            Log.d(
                    ConstantsUI.TAG,
                    "Problem postFile(), targetURL: " + targetURL + " HTTP response: "
                            + responseCode);
        }
        return responseCode + "";
    }

    return responseToString(conn.getInputStream());
}
 
Example 20
Project: NetCompile   File: TestSceneController.java   Source Code and License Vote up 4 votes
private void getProblemList(String id,String sch, String course, String semester, String test) throws IOException {
       String postParams = "studentId="+id;
       postParams += "&school=" + sch;
       postParams += "&course=" + course;
       postParams += "&semester=" + semester;
       postParams += "&test=" + test;
               
       String[] probList;
               
URL url = new URL(URL + "getProblemList.php");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
//con.setRequestProperty("User-Agent", USER_AGENT);

// For POST only - START
con.setDoOutput(true);
       OutputStream os = con.getOutputStream();
os.write(postParams.getBytes());
os.flush();
os.close();
// For POST only - END

int responseCode = con.getResponseCode();
//System.out.println("POST Response Code :: " + responseCode);

if (responseCode == HttpURLConnection.HTTP_OK) { //success
	BufferedReader in = new BufferedReader(new InputStreamReader(
			con.getInputStream()));
           String inputLine;
           StringBuffer response = new StringBuffer();

           while ((inputLine = in.readLine()) != null) {
               response.append(inputLine);
           }

           in.close();
           String res = response.toString();
           res = res.replaceAll("\\[", "").replaceAll("\\]","");
           probList = res.split(",", -1);
           // print result
           String dir = URL + "data/" + sch + "/" + course + "/" + semester + "/" + test + "/$admin";
           setTabs(probList, dir);
} else {
           System.out.println("POST request not worked");
}
   }