[Áú¹®:Ãʺ¸ÀÚ]ÀÌ·²¶© ¾î¶»°Ô Çؾߵdzª¿ä? (ÀÚ¹Ù¼­ºí¸´)


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :±è¼±Èñ 2000³â 1¿ù 27ÀÏ 11:04:02

JSDK2.0 »ç¿ë
¾Æ·¡ Äڵ带 ½ÇÇà½ÃÄ×À»¶§ 'submit' ¹öÆ°À» ´©¸£¸é


-----------------------------------------------
http://localhost/servlet/InputServlet2
¼­¹ö·ÎÀÇ ¿¬°áÀ» Àç¼³Á¤ ÇÏ¿´½À´Ï´Ù.
-----------------------------------------------
ÀÌ·± ¸Þ¼¼Áö°¡ ¶ß°Åµç¿ä..¾î¶»°Ô Çؾߵɱî¿ä?



import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;



public class InputServlet2 extends HttpServlet {


//¼­ºí¸´À» ÃʱâÈ­ÇÏ´Â ¸Þ¼Òµå
public void init(ServletConfig config) throws ServletException {

// ServletConfigÀÇ ÀνºÅϽº¸¦ »óÀ§Å¬·¡½º(HttpServlet) ¿¡ Àü´Þ
// »óÀ§Å¬·¡½ºÀÇ »ý¼ºÀÚ¸¦ È£Ãâ
super.init(config);
}

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException , IOException {

res.setContentType("text/html");

PrintWriter browserout = new PrintWriter(new OutputStreamWriter(res.getOutputStream(),"KSC5601"));

try {

String FileName = req.getParameterValues("survey")[0];

FileWriter file = new FileWriter(FileName + ".txt", true);

PrintWriter browseroutFile = new PrintWriter(file);

Enumeration values = req.getParameterNames();

// hasMoreElements : Tests if this enumeration contains more elements
// nextElement : Returns the next element of this enumeration
while (values.hasMoreElements()) {

String name = (String)values.nextElement();
String value = req.getParameterValues(name)[0];

if (name.compareTo("submit") != 0) {
browseroutFile.println(name + ":" + Uni2Ksc(value));
}
}

browseroutFile.close();

browserout.println("¸Þ½ÃÁö°¡ ÀúÀåµÇ¾ú½À´Ï´Ù.");

} catch (IOException e){

e.printStackTrace();
browserout.println(e.toString());
}

browserout.close();

}

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

res.setContentType("text/html; charset=euc-kr");

PrintWriter out = new PrintWriter(new OutputStreamWriter(res.getOutputStream(),"KSC5601"));

out.println("<html><body>");
out.println("<form action=\"InputServlet2\" method=\"POST\">");
out.println("<input type=\"hidden\" name=\"survey\" value=\"survey01Results\">");
out.println("<BR><BR>±Í»çÀÇ Á÷¿øÀº ¸î ¸íÀԴϱî<BR>");
out.println("<BR>1-100<input type=\"radio\" name=\"employee\" value=\"1-100\">");
out.println("<BR>100-200<input type=\"radio\" name=\"employee\" value=\"100-200\">");
out.println("<BR>200-300<input type=\"radio\" name=\"employee\" value=\"200-300\">");
out.println("<BR>300-400<input type=\"radio\" name=\"employee\" value=\"300-400\">");
out.println("<BR>500-more<input type=\"radio\" name=\"employee\" value=\"500ÀÌ»ó\">");
out.println("<BR><BR>³²±æ ¸»À» ½áÁÖ¼¼¿ä<BR>");
out.println("<BR><input type=\"text\" name=\"comment\">");
out.println("<BR><BR>ÁÖ·Î »ç¿ëÇÏ´Â java °³¹ßÅøÀº<BR>");
out.println("<BR>JavaWorkShop<input type=\"checkbox\" name=\"ide\" value=\"JavaWorkShop\">");
out.println("<BR>J++<input type=\"checkbox\" name=\"ide\" value=\"J++\">");
out.println("<BR>Cafe<input type=\"checkbox\" name=\"ide\" value=\"Cafe\">");
out.println("<BR><BR><input type=\"submit\"><input type=\"reset\">");
out.println("</form></body></html>");
out.flush();
out.close();
}


public String Uni2Ksc(String Unicodestr) throws UnsupportedEncodingException {

if (Unicodestr == null)
return null;

return new String(Unicodestr.getBytes("8859_1"), "KSC5601");

}


}


´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]