내 코드입니다 : POST 요청이 이미 이루어집니다 내가 showDocument 메소드를 사용하는 시간으로자바 : 페이지를 표시하는 동안 POST 요청을 보내는 방법은 무엇입니까?
try
{
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "png", os);
byte[] bytes = os.toByteArray();
os.flush();
os.close();
String code = encode(bytes);
URL base = applet.getCodeBase();
URL url = new URL(base.getProtocol(),
base.getHost(),
base.getPort(),
"/image.php?code=" + code);
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("POST");
c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
c.setDoOutput(true);
DataOutputStream s = new DataOutputStream(c.getOutputStream());
s.writeBytes("code=" + code);
applet.getAppletContext().showDocument(url, "_blank");
}
catch (Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(
this,
e.toString(),
"Error",
JOptionPane.ERROR_MESSAGE);
}
그래서 내가 정말 빈 페이지 (대신, 나는 이미지를 보여주고 싶은) 보여주는하고 있어요 . image.php의 소스는 이것이다 :
<?php
$code = base64_decode($_GET["code"]);
header('Content-Type: image/png');
echo $code;
?>