±Û¾´ÀÌ :xsuk 1998³â 7¿ù 22ÀÏ 08:50:50
Àú´Â Applet - servlet ¿¡¼ÀÇ ÇÑ±Û Ã³¸® ¿¡ ´ëÇؼ µµ¿òÀ» ¹Þ°íÀÚ ÇÕ´Ï´Ù.
´ÙÀ½Àº Applet ¿¡¼ servlet À» È£ÃâÇÑ ºÎºÐÀÔ´Ï´Ù.
============================================
url = new URL("http://¼¹öIP/servlet/SendFileServlet");
// URL connection channel.
urlConn = url.openConnection();
// Let the run-time system (RTS) know that we want input.
urlConn.setDoInput (true);
// Let the RTS know that we want to do output.
urlConn.setDoOutput (true);
// No caching, we want the real thing.
urlConn.setUseCaches (false);
// Specify the content type.
urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// Send POST output.
PrintWriter out = new PrintWriter(
new OutputStreamWriter(res.getOutputStream(), "KSC5601") );
String content =
"ServerName=" + URLEncoder.encode ("FileServer IP") +
"&UserID=" + URLEncoder.encode ("Password") +
"&Password=" + URLEncoder.encode ("UserID") +
"&FileName=" + URLEncoder.encode (strFileName);///ÇÑ±Û ÆÄÀϸí
printout.writeBytes (content);
printout.flush ();
printout.close ();
// Get response data.
input = new DataInputStream (urlConn.getInputStream ());
String str;
while (null != ((str = input.readLine())))
{
System.out.println (str);
//textArea.appendText (str + "\n");
}
input.close ();
==================================================
´ÙÀ½Àº servlet ºÎºÐÀÔ´Ï´Ù.
==========================================
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String strServerName = req.getParameterValues("ServerName")[0];
String strUserID = req.getParameterValues("UserID")[0];
String strPassword = req.getParameterValues("Password")[0];
String strFileName = req.getParameterValues("FileName")[0];
// Open a output stream so you can write to the client
PrintWriter out = new PrintWriter(
new OutputStreamWriter(res.getOutputStream(), "KSC5601") );
// Write header to client
res.setContentType("text/html");
......
===========================
±×·±µ¥ Çѱ۷Πº¸³½ filename ÀÌ ±úÁ®¼ ´Ù¸¥ ÀÛ¾÷À» ÇÒ ¼ö°¡ ¾ø½À´Ï´Ù.
String strFileName = req.getParameterValues("FileName")[0];
¾î¶»°Ô ÇÏ¸é ¼ºí¸´¿¡¼ ÇѱÛÀ» Á¦´ë·Î ¹ÞÀ» ¼ö ÀÖÀ»±î¿ä?
Decoding ÇÏ´Â ¼Ò½º¸¦ ÁÖ½Ã¸é ´õ¿í °í¸¿°Ú½À´Ï´Ù.
Á¦ ÁÖ¼Ò´Â xsuk@ditco.com