Tomcat 3.1 ¿¡ postgreSQLÀÇ JDBC ¿¬µ¿Àº ÀÇ¿Ü·Î °£´ÜÇÏ´Ù. ȯ°æº¯¼ö CLASSPATH ¿¡ µî·ÏÇϱ⸸ ÇÏ¸é µÈ´Ù. ±×·¯¸é Tomcat ½ÇÇà½Ã ÀÚµ¿À¸·Î ÀÐ¾î¼ JDBC ¸¦ ·ÎµùÇÑ´Ù.
CLASSPATH ¼³Á¤ ¿¹
export CLASSPATH=$CLASSPATH:/usr/local/pgsql7.0.2/jdbc/postgresql.jar
Tomcat ¿¡¼ÀÇ ÇѱÛ󸮴 Apache-Jserv ¿Í µ¿ÀÏÇÏ´Ù.
¾Æ·¡´Â °³·«ÀûÀÎ ¼Ò½ºÀÔ´Ï´Ù.
..............
..............
public void doGet(HttpServletRequest req , HttpServletResponse res)
throws ServletException,IOException
{
.......
.......
PrintWriter out;
res.setContentType("text/html;charset=euc-kr");
out=new PrintWriter(new OutputStreamWriter(
res.getOutputStream(),"KSC5601"));
.......
.......
}
.....
.....
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/html;charset=euc-kr");
PrintWriter out=new PrintWriter(new OutputStreamWriter(
res.getOutputStream(),"KSC5601"));
....
String id=ksc(req.getParameter("id"));
String name=ksc(req.getParameter("name"));
String juso=ksc(req.getParameter("juso"));
String tel=ksc(req.getParameter("tel"));
String memo=ksc(req.getParameter("memo"));
....
....
}
.....
.....
public String ksc(String kscstr)
throws UnsupportedEncodingException
{
if(kscstr==null) return null;
return new String(kscstr.getBytes("8859_1"),"KSC5601");
} // ksc() ÇÔ¼ö´Â ¹®ÀÚ¸¦ KSC5601·Î º¯È¯ÇÑ´Ù.
............................................................
¶ÇÇÑ Æ÷½ºÆ®±×·¹½º7.0.2¿¡ ÇѱÛÀ» »ðÀÔÇϱâÀü¿¡ KSC5601·Î º¯È¯ÇÏ¿©¾ß ÇÑ´Ù. ±×·¸Áö ¾ÊÀ¸¸é Æ÷½ºÆ®±×·¹½º¿¡ µé¾î°£ ÇѱÛÀº ¹Ù·Î ±úÁø´Ù. ±âŸ ´Ù¸¥ ¹öÁ¯Àº ¾Æ¸¶ ºñ½ÁÇÒ °Å·Î ÃßÃøµÇ¸ç ¾ÆÁ÷ Å×½ºÆ®´Â ¸øÇØ º¸¾Ò´Ù.
¾Æ·¡Ã³·³ ¹®ÀÚ¸¦ ksc()ÇÔ¼ö·Î ksc5601 ·Î º¯È¯ÇÑ ÈÄ¿¡ Æ÷½ºÆ®±×·¹½º¿¡ insert ÇÏ¸é µÈ´Ù.
String id=ksc(req.getParameter("id"));
String name=ksc(req.getParameter("name"));
String juso=ksc(req.getParameter("juso"));
String tel=ksc(req.getParameter("tel"));
String memo=ksc(req.getParameter("memo"));