[JSP] 기본 프레임

김윤섭·2023년 9월 7일
0

JSP

목록 보기
18/18
post-thumbnail

프론트 컨트롤러 기본프레임

package com.codingbox.board;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet
public class BoardFrontController extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		doProcess(req, resp);
	
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		doProcess(req, resp);
		
	}
	
	private void doProcess(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		
		String requestURI = request.getRequestURI();
		ActionForward forward = null;
		
		
		if( forward != null ) {
			if( forward.isRedirect() ) {
				// true : redirect
				response.sendRedirect(forward.getPath());
				
			} else {
				// false : forward
				RequestDispatcher disp = request.getRequestDispatcher(forward.getPath());
				disp.forward(request, response);
			}
		}
	}
	
	

DAO 기본 프레임


public class BoardDAO {
	
	SqlSessionFactory factory = SqlMapConfig.getFactory();
	SqlSession sqlsession;
	
	public BoardDAO() {
		sqlsession = factory.openSession(true);
	}
}    
profile
안녕하세요

0개의 댓글