public void doPost ( HttpServletRequest req, HttpServletResponse res ) 	throws ServletException,IOException {
String url = "jdbc:oracle:thin:@localhost:1521:etri" ;
Connection con ;
Statement stmt ;
InsertItem insertItem = new InsertItem ( ) ;
res.setContentType ( "text/html ;charset = euc-kr" ) ;
out = res.getWriter ( ) ;
name = req.getParameter ( "name" ) ;
email = req.getParameter ( "email" ) ;
title = req.getParameter ( "title" ) ;
content = req.getParameter ( "content" ) ;
password = req.getParameter ( "password" ) ;
BoardData data = new BoardData ( 0, null, title, name, email, password, content ) ;
try {
insertItem.loadDriver ( ) ;
}
catch ( java.lang.ClassNotFoundException e ) {
System.err.print ( "ClassNotFoundException:" ) ;
System.err.println ( e.getMessage ( ) ) ;
} catch ( Exception e ) {
System.err.println ( e ) ;
}
out.println ( "<html><head><title>글 작성</title>" ) ;
out.println ( "</head>" ) ;
out.println ( "<body background = /images/back.gif>" ) ;
try {
insertItem.insert ( data, req.getRemoteAddr ( ) ) ;
out.println ( "<script>alert ( '자료가 추가되었습니다.' ) ;self.location = 'BoardList_db'</script>" ) ;
} catch ( SQLException ex ) {
System.err.println ( "SQLException : " + ex.getMessage ( ) ) ;
out.println ( "<script>alert ( '자료 추가에 실패하였습니다.' ) ;history.back ( ) </script>" ) ;
}
out.println ( "</body></html>" ) ;
}
public String toHangul ( String str ) {
if ( str == null ) return null;
try {
return new String ( str.getBytes ( "8859_1" ) , "KSC5601" ) ;
} catch ( UnsupportedEncodingException e ) {
}
return null ;
}
public String hangulTo ( String str ) {
if ( str == null ) return null;
try {
return new String ( str.getBytes ( "KSC5601" ) , "8859_1" ) ;
} catch ( UnsupportedEncodingException e ) {
}
return null ;
}
