jsp¸¦ È°¿ëÇؼ ¹æ¹®ÀÚÄ«¿îÆ® ¼Ò½º¸¦ Â¥°íÀִµ¥¿ä
ÀÚ²Ù ¿À·ù°¡³ª¼ Áú¹®µå¸³´Ï´Ù.
ÀÏ´Ü ÀÌ ¼Ò½ºÀÇ Á¶°ÇÀº
»õ·Î°íħÇßÀ»°æ¿ì Áߺ¹µÇ¾î Ä«¿îÆ® µÇÁö¾Ê°í, Çϵå¾ÈÀÇ count.txtÆÄÀÏ¿¡ Ä«¿îÆÃÀÌ ÀúÀåµÇ¼
ÅèĹÀÌ »õ·Î ÀÛµ¿µÇ´õ¶óµµ Ä«¿îÆ®°¡ ¸®¼ÂµÇÁö¾Ê´Â Á¶°ÇÀÇ ¼Ò½ºÀÔ´Ï´Ù.
<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import = "java.io.*" %>
<%
String readResourcePath = "/ch08/count.txt";
String writeResourcePath = readResourcePath;
String realReadPath = //application.getRealPath//(readResourcePath);
String realWritePath = //application.getRealPath//(writeResourcePath);
BufferedReader br = null;
PrintWriter pr = null;
String count = null;
try {
br = new BufferedReader(new FileReader(realReadpath));
count = br.readLine().trim();
br.close();
//if (session.isNew()) {//
pr = new PrintWriter (new FileWriter(realWritePath));
//int num = Integer.parseInt(count);//
pr.println(num+1);
pr.close();
}
}catch(IOException ex) {
out.println("¿¹¿Ü¹ß»ý: " + ex.getMessage());
}
%>
¹æ¹®ÀÚ¼ö : <%= count %>¸í
//·Î Ç¥½ÃµÈºÎºÐÀÌ Á¦°¡ ä¿ö³Ö¾î¾ßÇÏ´Â ºóÄÀε¥
¾Æ¹«·¡µµ if¿Í intºÎºÐ¿¡¼ ¿À·ù°¡ ¹ß»ýÇϴ°Ͱ°Àºµ¥
¾î¶»°Ô°íÄ¡¸é ¿À·ù°¡ ¾øÀ»±î¿ä?
Á¤´äº¸´Ùµµ ¿ø¸®¿Í Çؼ®ÀûÀÎÀÌÀ¯¸¦ ¼³¸íÇØÁÖ½Ã¸é °¨»çÇÏ°Ú½À´Ï´Ù(__) | |
|
count°¡ null À̰ųª ¹®ÀÚÀÏ°æ¿ì¿¡ intÇüÀ¸·Î ¹Ù²Ù¸é¼ ¿À·ù°¡ ³¯°Å °°Àºµ¥¿ä.