ServletÀÌ ÀÛµ¿ÀÌ Àß ¾ÈµÇ¿ä !! SOS


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

±Û¾´ÀÌ :±è¼øÀÚ 1999³â 7¿ù 23ÀÏ 10:37:39

¾È³çÇϼ¼¿ä. Àú´Â ¼­ºí¸´À» °øºÎÇÏ°í ÀÖ´Â ¿ÕÃʺ¸ ÀÔ´Ï´Ù.
Á¦°¡ sorce¸¦ ¹Þ¾Æ¼­ ½ÇÇàÀ» ½ÃÅ°´Âµ¥ Á¦´ë·Î ½ÇÇàÀÌ µÇÁö ¾Ê½À´Ï´Ù. Àú´Â jsw2.0À» ¾²°í ÀÖ±¸¿ä.servletsµð·ºÅ丮 ¹Ø¿¡´Ù class È­ÀÏÀ» ³Ö¾ú´Âµ¥¿ä. ½ÇÇà È­¸éÀÌ ¾Æ¹«°Íµµ µé¾î ÀÖÁö ¾ÊÀº ¹éÁö È­¸éÀÔ´Ï´Ù. ¼Ò½º¸¦ °°ÀÌ º¸³¾Å×´Ï ÀÌÀ¯Á» ¾Ë·Á ÁÖ¼¼¿ä...


<html>
<head><title></title></head>
<body>
<form action = "http://210.111.22.115:8080/servlet/NewUserServlet" method = post>
<br><br>´ç½ÅÀÇ À̸§ÀÌ ¹«¾ùÀΰ¡¿ä?<br>
<br>À̸§ : <input type = "text" name = "name">
<br><br>´ç½ÅÀÇ ³ªÀÌ´Â ¸î»ìÀÎÁö¿ä?<br>
<br>³ªÀÌ : <input type = "text" name = "age">
<br><br><br>
<input type = "submit" value = "°¡ÀÔ½Åû">
<input type = "reset" value = "°¡ÀÔÃë¼Ò">
</form>
</body>
</html>


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


public class NewUserServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String userName = null;
String userAge = null;


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


//try {
userName = req.getParameter("name");
userName = new String(userName.getBytes("iso-8859-1"), "euc-kr");
userAge = req.getParameter("age");


toClient.println("<html><head><title>ȸ¿ø°¡ÀÔ½Åû</title></head><body>");
toClient.println("<center><h3>");
toClient.println("<br>´ÙÀ½°ú °°ÀÌ È¸¿ø°¡ÀÔ½ÅûÀÌ µÇ¾ú½À´Ï´Ù.");
toClient.println("<br>ȸ¿ø À̸§ : " + userName);
toClient.println("<br>ȸ¿ø ³ªÀÌ : " + userAge);
toClient.println("<br><br>°¡ÀÔ󸮴 ¸ÅÁÖ ¿ù¿äÀÏ¿¡ ÀÖ½À´Ï´Ù.");
toClient.println("</h3></center>");
toClient.println("</body></html>");
toClient.close();
/*} catch(NullPointerException npe) {
toClient.println("À̸§°ú ³ªÀ̸¦ ÀÔ·ÂÇØ ÁֽʽÿÀ.");
} catch(IOException e) {
e.printStackTrace();
toClient.println("ȸ¿ø °¡ÀÔ Ã³¸® Áß ´ÙÀ½°ú °°Àº ¿¹¿Ü»óȲÀÌ ¹ß»ý.\n" + e.getMessage());
}
*/
toClient.close();
}
}


´ÙÀ½ ±Ûµé:



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

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


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