jsp

    DB 프로그래밍

    Class.forName(“com.mysql.jdbc.Driver”); // JDBC 드라이버의 클래스 등록 Connection conn; Statement stmt = conn.createStatement(); select문 ResultSet executeQuery(String sql) ; // 결과로 ResultSet 객체를 반환 example) ResultSet rs = stmt.executeQuery("select name, id, age from tbl"); insert, update, delete 문 int executeUpdate(String sql); // 결과로 오류여부를 반환 생성객체 닫기 rs.close(); // ResultSet을 닫는 메소드 stmt.close(); // Stat..

    쿠키(Cookie) & 세션(Session)

    쿠키(Cookie) 생성 Cookie c = new Cookie("이름", 값); 시간 설정 c.setMaxAge(24 * 60 * 60); 쿠키 추가 response.addCookie(c); 쿠키 목록 얻기 Cookie[] allValues = request.getCookies(); 쿠키 값 얻기 allValues[i].getValues(); 세션(Session) 생성 HttpSession session = request.getSession(); 설정 session.setAttribute("이름", 값); 얻기 session.getAttribute("이름"); 삭제 session.removeAttribute("이름"); 시간설정 session.setMaxInactiveInterval(시간); 종료 se..

    Application 내장 객체

    xml 설정 값 String driver = application.getInitParameter("값"); web.xml 설정 url jdbc.oracle.thin:@localhost:1521:oracle 코딩 내 설정 application.setAttribute("이름", 값); application.getAttribute("이름");

    Forward & Redirect & Include

    JSP Forward Basic Parameter 1 Parameter 2 request.setAttribute("파라미터 이름", "파라미터 값"); Redirect Basic response.sendRedirect(String location); Parameter 1 Parameter 2 (GET) // 특수문자를 url에 포함시킬 때 필요한 코딩 Include Include Directive tag Include Action tag 파라미터 넘기기 Servlet Forward RequestDispatcher dis = request.getRequestDispatcher("page.jsp"); dis.forward(request, response); Redirect response.sendRedire..

    파라미터 값 받기 & 한글 처리

    request.getParemeter(String name) 리턴타입 : String 용도 : 해당 name값을 알고 있을 때 request.getParameterValues(String name) 리턴타입 : String[] 용도 : Name에 해당하는 Value값이 여러 개인 경우 request.getParameterNames() 리턴타입 : Enumeration 용도 : 폼 데이터가 많거나 name값을 모르는 경우 한글 인코딩 처리 코드 request.setCharacterEncoding("EUC-KR"); response.setContentType("text/html;charset=euc-kr");

    JSP Page Directive

    Info 기본값 : 없음 페이지를 설명해주는 문자열 지정 Language 기본값 : “java” JSP 페이지에서 사용할 언어 지정 contentType 기본값 : “text/html” JSP 페이지 내용이 어떤 형태로 출력할 것인지를 지정 Extends 기본값 : 없음 JSP 페이지가 서블릿으로 변환할 때 상속받을 클래스 지정 Import 기본값 : 없음 JSP 페이지에서 다른 package의 클래스를 import할 때 지정 Session 기본값 : “true” JSP페이지가 httpSession 객체를 사용할지를 지정 Buffer 기본값 : “8kb” JSP페이지의 출력크기를 지정할 때 사용 autoFlush 기본값 : “true” JSP페이지의 내용들이 출력되기 전 버퍼가 다 할 경우 동작을 지정 ..