%@ page import = "java.io.*,java.util.*,java.net.http.*,java.net.URI,java.net.http.HttpResponse.BodyHandlers,java.net.HttpURLConnection,java.net.URL,java.nio.charset.StandardCharsets,org.json.*" %> <%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> debug <% String titleId = request.getParameter("titleId") == null ? "" : request.getParameter("titleId"); String targetURL = "http://127.0.0.1:8082/getTitle?titleId=" + titleId; %> <% StringBuilder res = new StringBuilder(); try { URL url = new URL(targetURL); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); int responseCode = connection.getResponseCode(); BufferedReader reader; if (responseCode == HttpURLConnection.HTTP_OK) { reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); } else { reader = new BufferedReader(new InputStreamReader(connection.getErrorStream())); } String line; while ((line = reader.readLine()) != null) { res.append(line); } reader.close(); } catch (Exception e) { //e.printStacktrace(); } String games = res.toString(); //Tmd size stuff String tmdUrl = "http://198.62.122.200/ccs/download/" + titleId + "/tmd"; StringBuilder tmdRes = new StringBuilder(); long tmdSize = 0; try { URL url = new URL(tmdUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); tmdSize = connection.getContentLengthLong(); int responseCode = connection.getResponseCode(); BufferedReader reader; if (responseCode == HttpURLConnection.HTTP_OK) { reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); } else { reader = new BufferedReader(new InputStreamReader(connection.getErrorStream())); } String line; //String contentLength = connection.getHeaderField("Content-Length"); //tmdSize = contentLength; while ((line = reader.readLine()) != null) { tmdRes.append(line); } reader.close(); } catch (Exception e) { //e.printStacktrace(out); res.append("Error: ").append(e.getMessage()); } %> <% // Parse JSON response JSONObject title = new JSONObject(games); String id = title.getString("id"); String thumbnail = title.getString("thumbnail"); String title1 = title.getString("title1"); String title2 = title.getString("title2"); String platform = title.getString("console"); if (platform.equals("WII")) { platform = "Wii Channels"; } else if (platform.equals("WIIWARE")) { platform = "WiiWare"; }; String releaseDate = title.getString("date"); String genre = title.getString("genre"); String publisher = title.getString("publisher"); String points = title.getString("points"); String players = title.getString("players"); String ratingDetails = title.getString("ratingdetails"); String rating = title.getString("rating").toUpperCase(); String controllers = title.getString("controllers"); String size = title.getString("size"); String latestVersion = title.getString("titleVersion"); %>