/* 
    IntraPMS Project
    팀 관리를 한 후 모든 부서를 보여주는 서블릿

    
*/
import java.io.* ;
import javax.servlet.* ;
import javax.servlet.http.* ;

import java.util.*;

import java.sql.DriverManager ;
import java.sql.Connection ;
import java.sql.Statement ;
import java.sql.ResultSet ;
import java.sql.SQLException ;

import com.etri.groupware.*;
import com.etri.groupware.organization.*;

public class ShowAllTeamServlet extends HttpServlet
{
	GroupwareControllerInterface gc = null ;
	OrganizationManagementControllerInterface  omc = null ;
	Properties myPro = null ;

	public void init ( ServletConfig config ) throws ServletException {
		super.init ( config ) ;
		System.out.println ( "ShowAllTeamServlet init () Call..........." ) ;
		
		// 그룹웨어 컨트롤러를 생성한다.
		// 먼저 프라퍼티를 생성한다.
		myPro = new Properties ( ) ;
		// DB매니저 구현 클래스 이름 설정
		myPro.put ( "OrganizationDBManagerClassName" , "PandaSoftOrganizationDBManager" ) ;
		myPro.put ( "BBSDBManagerClassName" , "PandaSoftBBSDBManager" ) ;
		myPro.put ( "EDADBManagerClassName" , "PandaSoftEDADBManager" ) ;
		myPro.put ( "MailDBManagerClassName" , "PandaSoftMailDBManager" ) ;
		////////////////////////////////////////
		System.out.println ( "모든 팀을 보여주는 서블릿의 프라퍼티 설정을 무사히 마쳤습니다." ) ;
		
		try {
			gc = GroupwareController.init ( myPro ) ;
			/////////////////////////////////////////////////
			System.out.println ( "모든 팀을 보여주는 서블릿에서 사용하는 그룹웨어 컨트롤러 생성을 무사히 마쳤습니다." ) ;
			
			// 조직도 관리 컨트롤러를 가져온다.
			omc = gc.createOrganizationManagementController ( ) ;
			///////////////////////////////////////////////////////////
			System.out.println ( "모든 팀을 보여주는 서블릿에서 사용하는 조직도 관리 컨트롤러 생성도 무사히 마쳤습니다." ) ;
		} catch ( Exception e ) { }
	}
	
	public void destroy ( ) {
		super.destroy();
		DBConnectionManager.instance.release() ;
		System.out.println ( "ShowAllTeamServlet destroy () Call..........." ) ;
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: doGet<br>
	 [기능]: 팀 관리를 한 후 모든 팀을 보여준다.<br>
	 [파라미터]: HttpServletRequest request, HttpServletResponse response<br>
	 [호출자] : 사용자<br>
	 */
	/*--------------------------------------------------------------- */			
	public void doGet (
		HttpServletRequest request ,
		HttpServletResponse response ) throws ServletException , IOException
	{
		PrintWriter out ;
		String head = " 팬더 소프트 " ;
		// Set content type and other response header fields first
		response.setContentType ( "text/html;charset=euc-kr" ) ;
		// then write the data of the response
		out = new PrintWriter ( new OutputStreamWriter ( response.getOutputStream ( ) , "EUC-KR" ) ) ;
		
		/////////////////////////////////////////////
		// 세션 확인 부분 - 인증되지 않은 사용자의 경우 Login.html 로 되돌려 보낸다.
		String authenKind = null ;
		String authenId = null ;
		String authenName = null ;
		String authenLoginStatus = null;
		
		HttpSession session = request.getSession ();
		authenLoginStatus =  (String)session.getValue("Authentication");
		
		if( (authenLoginStatus == null) || ( !(authenLoginStatus.equals("true")) ) ){
			session.invalidate();
			response.sendRedirect("../Login.html");
		} else {
			authenKind = (String)session.getValue("Kind");
			authenId = (String)session.getValue("Id");
			authenName = (String)session.getValue("Name");   
		}
		/////////////////////////////////////////////

		// 데이타베이스에서 얻어들 모든 부서의 내용으로 String의 배열형태이다.
		Team[] allTeam = null ;
		boolean isUpdateTree = false ;
		boolean isSearch = false ;
		String original = null ;
		String page = request.getParameter("page");		
		page = new String ( page.getBytes("ISO-8859-1") , "EUC-KR" ) ;
		System.out.println ( page+ "입니다." ) ;	
		
		String name = request.getParameter ( "name" ) ;
				
		// 폼 태그에서 넘어온 한글과 그냥 파라미터로 넘어온 한글 처리가 달라야 한다.
		if ( request.getParameter("form") != null ) {
			// 폼 태그로부터 넘어온 파라미터의 경우이다.
			name = new String ( name.getBytes("ISO-8859-1") , "EUC-KR" ) ;			
		} 

		if ( ((request.getParameter("back")==null)&&(request.getParameter("upDepartment")!=null)) || (name.equals("searchResult")) ) {
			String upDepartment = null ;
			String weightWork = null ;
			String webURL = null ;
			String developField = null ;
			String teamExplain = null ;
			Team newTeam = null ;
			
			if ( name.equals("searchResult") ) {
				// 검색 결과의 다음 페이지 이다....
			} else {
				
			// 등록하기 버튼이 눌러졌을 경우에 새로운 팀을 등록하고 이 부서의 팀 리스트를 보여준다.
			upDepartment = request.getParameter("upDepartment") ;
			upDepartment = new String ( upDepartment.getBytes("ISO-8859-1") , "EUC-KR" ) ;
			weightWork = request.getParameter("weightWork") ;
			weightWork = new String ( weightWork.getBytes("ISO-8859-1") , "EUC-KR" ) ;
			webURL = request.getParameter("webURL") ;
			webURL = new String ( webURL.getBytes("ISO-8859-1") , "EUC-KR" ) ;
			developField = request.getParameter("developField") ;
			developField = new String ( developField.getBytes("ISO-8859-1") , "EUC-KR" ) ;
			teamExplain = request.getParameter("teamExplain") ;
			teamExplain = new String ( teamExplain.getBytes("ISO-8859-1") , "EUC-KR" ) ;
				
			newTeam = new Team ( ) ;
			newTeam.setName ( name ) ;
			newTeam.setUpDepartment ( upDepartment ) ;
			newTeam.setWeightWork ( weightWork) ;
			newTeam.setWebURL ( webURL ) ;
			newTeam.setDevelopField ( developField ) ;
			newTeam.setTeamExplain ( teamExplain ) ;
			
			}
			
			if ( request.getParameter ( "delete" ) != null ) {
				// 삭제하기 버튼을 눌렀을 경우....
				omc.deleteTeam ( newTeam ) ;
				// 데이타 베이스에서 삭제했습니다.		
				isUpdateTree = true ;

				name = upDepartment ;
				// 이름이 넘겨받은 부서인 부서 객체를 하나 생성한다.
				Department dep = new Department ( ) ;
				dep.setName ( name ) ;
				allTeam = omc.getAllTeam ( dep ) ;
			} else if ( request.getParameter ( "update" ) != null ) {
				// 변경하기 버튼을 눌렀을 경우....
				omc.updateTeam ( newTeam ) ;
				// 데이타 베이스에 업 데이트했습니다.		

				name = upDepartment ;
				// 이름이 넘겨받은 부서인 부서 객체를 하나 생성한다.
				Department dep = new Department ( ) ;
				dep.setName ( name ) ;
				allTeam = omc.getAllTeam ( dep ) ;				
			} else if ( request.getParameter ( "search" ) != null ) {
				// 검색하기 버튼을 눌렀을 경우....
				isSearch = true ;
				// 검색을 하기전에 있던 부서를 가지고 있다가 검색된 팀이 없으면 그 부서로 다시 돌아간다.
				original = request.getParameter("original") ;
				original = new String ( original.getBytes("ISO-8859-1") , "EUC-KR" ) ;	

				TeamSearchProperty tsp = new TeamSearchProperty ( ) ;
				tsp.setName ( name ) ;
				tsp.setUpDepartment ( upDepartment ) ;
				tsp.setWeightWork ( weightWork ) ;
				if ( request.getParameter ( "orAnd" ).equals ( "or" ) ) {
					tsp.setOrOrAnd ( true ) ;
				} else {
					tsp.setOrOrAnd ( false ) ;
				}
				tsp.setDevelopField ( developField ) ;
				tsp.setTeamExplain ( teamExplain ) ;
				// 데이타 베이스에서 검색되어진 모든 부서의 내용을 가져온다.
				allTeam= omc.searchTeam ( tsp ) ;
				name = "searchResult" ;
				// 검색 결과를 저장하자.....
				TeamSearchResult.setSearchTeam ( allTeam ) ;
			} else if ( name.equals ( "searchResult" ) ) {
				// 저장된 검색 결과를 가져온다.
				isSearch = true ;
				allTeam = TeamSearchResult.getSearchTeam ( ) ;
			} else {
				// 등록하기 버튼을 눌렀을 경우...
				OrganizationResultStatus ors = omc.addTeam ( newTeam ) ;
				if ( ors.getResultStatus() == 1 ) {
					// 입력하는것에 실패했을 경우
					out.println ( "<html><head><title>에러</title></head>" ) ;
					out.println ( "<body><p align=\"center\">에러가 발생했습니다.</p>" ) ;
					out.println ( "<p align=\"center\">이미 존재하는 팀 이름입니다.</p>" ) ;
					out.println ( "<p align=\"center\">" + ors.getReason() + "</p>" ) ;
					out.println ( "<input type=\"hidden\" name=\"upDep\" value=\"" + upDepartment + "\">" ) ;
					out.println ( "<p align=\"center\"><input type=\"button\" name=\"add\" value=\"되돌아 가기\" onClick=\"history.back();\"></p>" ) ;
					out.println ( "</body></html>" ) ;
					out.close ( ) ;
				}
				isUpdateTree = true ;
				
				name = upDepartment ;
				// 이름이 넘겨받은 부서인 부서 객체를 하나 생성한다.
				Department dep = new Department ( ) ;
				dep.setName ( name ) ;
				allTeam = omc.getAllTeam ( dep ) ;
			}
		} else {
			if ( (request.getParameter("upDepartment")!=null) && (request.getParameter("original")==null) ) {
				// 되돌아가기 버튼이 눌러 졌을 경우에 수행된다.
				String upDepartment = request.getParameter("upDepartment") ;
				upDepartment = new String ( upDepartment.getBytes("ISO-8859-1") , "EUC-KR" ) ;
				name = upDepartment ;
			} else if ( request.getParameter ( "original" ) != null ) {
				// 되돌아가기 버튼이 눌러 졌을 경우에 수행된다.
				String upDepartment = request.getParameter("original") ;
				upDepartment = new String ( upDepartment.getBytes("ISO-8859-1") , "EUC-KR" ) ;
				name = upDepartment ;
			} else {
			}
		
			// 이름이 넘겨받은 부서인 부서 객체를 하나 생성한다.
			Department dep = new Department ( ) ;
			dep.setName ( name ) ;
			
			// 데이타 베이스에서 파라미터로 넘겨주는 부서의 모든 팀의 내용을 가져온다.
			allTeam = omc.getAllTeam ( dep ) ;
		}

		out.println ( "<html><head><title>팬더 소프트" + name + "</title>" ) ;
		out.println ( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=euc-kr\">" ) ;
		out.println ( "<style type=\"text/css\">" ) ;
		out.println ( "BODY {font-size:9pt; color:\"#000000\"; line-height:14px;}" ) ;
		out.println ( "A:Link {font-size:9pt; color:\"#000033\"; line-height:14px; text-decoration:none}" ) ;
		out.println ( "A:Visited {font-size:9pt; color:\"#330033\"; line-height:14px; text-decoration:none}" ) ;
		out.println ( "A:Hover {font-size:9pt; color:\"#0000ff\"; line-height:14px; text-decoration:underline}" ) ;
		out.println ( "td {font-size:9pt;}" ) ;
		out.println ( "td.red {font-size:9pt; color:\"#ff0000\"}" ) ;
		out.println ( "td.black {font-size:9pt; color:\"#000000\"}" ) ;
		out.println ( "td.navy {font-size:9pt; color:\"#000066\"}" ) ;
		out.println ( "td.space {font-size:1pt;}" ) ;
		out.println ( "</style>  </HEAD>" ) ;
		
		if ( isUpdateTree ) {
			// 조직도 트리를 업데이트 시켜 준다.
			out.println ( "<body onLoad=\"updateOrgTree()\">" ) ;
		} else {
			out.println ( "<body>" ) ;
		}
		
		out.println ( "<p align=right><img src=\"/image/우측_관리기능.gif\" alt=\"관리 기능\"></p>" ) ;
		
		out.println ( "<script language=\"JavaScript\">" ) ;
		out.println ( "<!--" ) ;
		out.println ( "	function updateOrgTree()" ) ;
		out.println ( "	{ " ) ;
		out.println ( "		parent.frames[\'contents\'].location=\"/servlet/ShowOrganizationTreeServlet\"; " ) ;
		out.println ( "	} " ) ;		
		out.println ( "	function Back_Click()" ) ;
		out.println ( "	{ " ) ;
		out.println ( " history.back() ;" ) ;
		out.println ( "	} " ) ;
		out.println ( "//-->" ) ;
		out.println ( "</script>" ) ;
		out.println ( "<table border=0 hspace=4 width=\"100%\" cellpadding=3><tr><td>" ) ;				
		out.println ( "<form><table border=0 hspace=4 width=800 cellpadding=3><tr width=800><td width=340>" ) ;	
		if ( isSearch ) {
			out.println ( "<a href=\"/servlet/ShowOrganizationTreeServlet\" target=\"contents\" onClick=\"parent.frames[\'detail\'].location=\'/orgdetail.html\'\">조직관리</a></font>" ) ;
			out.println ( "</td><td width=460 align=right>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?add=add\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depAdd.src='/image/부서등록-1.jpg'\" onMouseOut=\"document.forms[0].depAdd.src='/image/부서등록.jpg'\"><img name=depAdd src=\"/image/부서등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?search=search\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depSea.src='/image/부서검색-1.jpg'\" onMouseOut=\"document.forms[0].depSea.src='/image/부서검색.jpg'\"><img name=depSea src=\"/image/부서검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?add=add&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temAdd.src='/image/팀등록-1.jpg'\" onMouseOut=\"document.forms[0].temAdd.src='/image/팀등록.jpg'\"><img name=temAdd src=\"/image/팀등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?search=search&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temSea.src='/image/팀검색-1.jpg'\" onMouseOut=\"document.forms[0].temSea.src='/image/팀검색.jpg'\"><img name=temSea src=\"/image/팀검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?add=add&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offAdd.src='/image/사원등록-1.jpg'\" onMouseOut=\"document.forms[0].offAdd.src='/image/사원등록.jpg'\"><img name=offAdd src=\"/image/사원등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?search=search&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offSea.src='/image/사원검색-1.jpg'\" onMouseOut=\"document.forms[0].offSea.src='/image/사원검색.jpg'\"><img name=offSea src=\"/image/사원검색.jpg\"></a>" ) ;
			out.println ( "</td></tr><tr width=800 valign=middle bgcolor=\"#3399ff\"><td colspan=2 width=800><nobr><FONT color=#ffffff>팀 검색 결과</nobr></td></tr></table>" ) ;
		} else {
			out.println ( "<a href=\"/servlet/ShowOrganizationTreeServlet\" target=\"contents\" onClick=\"parent.frames[\'detail\'].location=\'/orgdetail.html\'\">조직관리</a></font>" ) ;
			out.println ( "</td><td width=460 align=right>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?add=add\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depAdd.src='/image/부서등록-1.jpg'\" onMouseOut=\"document.forms[0].depAdd.src='/image/부서등록.jpg'\"><img name=depAdd src=\"/image/부서등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchDepartmentServlet?search=search\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].depSea.src='/image/부서검색-1.jpg'\" onMouseOut=\"document.forms[0].depSea.src='/image/부서검색.jpg'\"><img name=depSea src=\"/image/부서검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?add=add&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temAdd.src='/image/팀등록-1.jpg'\" onMouseOut=\"document.forms[0].temAdd.src='/image/팀등록.jpg'\"><img name=temAdd src=\"/image/팀등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchTeamServlet?search=search&upDep=upDep\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].temSea.src='/image/팀검색-1.jpg'\" onMouseOut=\"document.forms[0].temSea.src='/image/팀검색.jpg'\"><img name=temSea src=\"/image/팀검색.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?add=add&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offAdd.src='/image/사원등록-1.jpg'\" onMouseOut=\"document.forms[0].offAdd.src='/image/사원등록.jpg'\"><img name=offAdd src=\"/image/사원등록.jpg\"></a>" ) ;
			out.println ( "<a onClick=\"parent.frames[\'detail\'].location=\'/servlet/AddSearchOfficialServlet?search=search&upDep=null&team=null\'\" style=\"cursor:hand;\" onMouseOver=\"document.forms[0].offSea.src='/image/사원검색-1.jpg'\" onMouseOut=\"document.forms[0].offSea.src='/image/사원검색.jpg'\"><img name=offSea src=\"/image/사원검색.jpg\"></a>" ) ;
			out.println ( "</td></tr><tr width=800 valign=middle bgcolor=\"#3399ff\"><td colspan=2 width=800><nobr><FONT color=#ffffff>" + name + "의 모든 팀 보기" + "</nobr></td></tr></table></form>" ) ;
		}		
		out.println ( "<p><p><!--------바뀌는  테이블------------>" ) ;
		out.println ( "<!--td align=\"center\" valign=\"top\"--> " ) ;
		out.println ( "<p><p><center><table width=\"731\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> " ) ;
		out.println ( "  <tr> " ) ;
		out.println ( "    <td width=\"10\">&nbsp;</td>" ) ;
		out.println ( "    <td width=\"10\">&nbsp;</td>"  ) ;
		out.println ( "    <td width=\"711\">&nbsp;</td>" ) ;
		out.println ( "  </tr>  <tr> " ) ;
		out.println ( "    <td width=\"10\">&nbsp;</td>" ) ;
		out.println ( "    <td width=\"10\">&nbsp;</td>" ) ;
		out.println ( "    <td width=\"711\">&nbsp;</td>" ) ;
		out.println ( "  </tr>  <tr> " ) ;
		out.println ( "    <td width=\"10\">&nbsp;</td>" ) ;
		out.println ( "    <td width=\"10\">&nbsp;</td>" ) ;
		out.println ( "    <td width=\"711\">&nbsp;</td>" ) ;
		out.println ( "  </tr></table>" ) ;
		out.println ( "<table width=\"710\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">" ) ;
		out.println ( "	<tr>	<td>&nbsp;&nbsp;&nbsp;</td>	<td>" ) ;
		out.println ( "<table border=0 cellpadding=2 cellspacing=0 bgcolor=#3399ff>" ) ;
		out.println ( "<tr><td width=600>" ) ;
		out.println ( "<table width=\"710\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">" ) ;
		out.println ( "	<tr>	<td width=130 align=center bgcolor=#3399ff>팀 이름</td>" ) ;
		out.println ( "	<td width=290 align=center bgcolor=#3399ff>팀 상위 부서</td>" ) ;
		out.println ( "	<td width=290 align=center bgcolor=#3399ff>팀 개발 분야</td>" ) ;
		out.println ( "	</tr>" ) ;
			
		////////////////////////////////////////////////////
		// 페이지를 위해 부서의 갯수를 알아내자....
		int dbNumber = 0 ;
		for ( dbNumber = 0 ; !(allTeam[dbNumber].getName().equals("null")) ; dbNumber++ ) { }
		// 지금부터는 [dbNumber] 가 총 부서의 갯수이다.
		////////////////////////////////////////////////////
		// 이제 총 페이지의 갯수를 알아내자..
		int pageNumber = dbNumber/4 ;
		if ( dbNumber%4 != 0 ) pageNumber++ ;
		// 파라미터로 현재 페이지를 얻어낼수 있다.
		// 파라미터로 넘어온 현재 페이지는 curPage이다.
		System.out.println ( page ) ;
		int curPage = Integer.parseInt ( page ) ;
		// 현재 페이지의 수에 맞추어서 튜플을 건너 뛰어야한다.
		int loop = ((curPage-1)*4) ;
		/////////////////////////////////////////////////
		// 라스트 페이지를 구해보자.
		int last = 0 ;
		if ( (pageNumber%3)==1 ) last = pageNumber ;
		else if ( (pageNumber%3)==2 ) last = pageNumber-1 ;
		else if ( (pageNumber%3)==0 ) last = pageNumber-2 ;
		String lastPage = new String ( Integer.toString ( last ) ) ;
		// Pre 페이지를 구해보자.
		int pre = 0 ;
		if ( (curPage%3)==1 ) pre = curPage-3 ;
		else if ( (curPage%3)==2 ) pre = curPage-4 ;
		else if ( (curPage%3)==0 ) pre = curPage-5 ;
		String prePage = new String ( Integer.toString ( pre ) ) ;
		// Next 페이지를 구해보자.
		int next = 0 ;
		if ( (curPage%3)==1 ) next = curPage+3 ;
		else if ( (curPage%3)==2 ) next = curPage+2 ;
		else if ( (curPage%3)==0 ) next = curPage+1 ;
		String nextPage = new String ( Integer.toString ( next ) ) ;
		// curPage에 대한 것들을 String으로 바꾸자.
		// curPage ( int ) 이고 page ( String ) 입니다.
		String mmPage = new String ( Integer.toString ( curPage-2 ) ) ;
		String mPage = new String ( Integer.toString ( curPage-1 ) ) ;
		String pPage = new String ( Integer.toString ( curPage+1 ) ) ;
		String ppPage = new String ( Integer.toString ( curPage+2 ) ) ;
		/////////////////////////////////////////////////////////////////
		System.out.println ( "페이지에 관한 모든 것들을 알아 냈습니다." ) ;
		boolean stop = false ;						

		out.println ( "    <tr>" ) ;
		if ( allTeam[loop].getName().equals("null") ) {
			stop = true ;
		} else {
			out.println ( "<TD bgcolor=\'#f7f7f7\'><a href=\"/servlet/ShowAllOfficialServlet?page=1&name=" + allTeam[loop].getName() + "&upDep=" + allTeam[loop].getUpDepartment() + "\" target=\"detail\">" + allTeam[loop].getName() + "</A></TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getUpDepartment() + "</TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getDevelopField() + "</TD>" ) ;

			loop++ ;
		}
		out.println ( "    </tr>" ) ;
		out.println ( "    <tr>" ) ;

		if ( allTeam[loop].getName().equals("null") ) {
			stop = true ;
			out.println ( "<TD bgcolor=\'#f7f7f7\'>&nbsp;</TD><TD bgcolor=\'#f7f7f7\'>&nbsp;</TD><TD bgcolor=\'#f7f7f7\'>&nbsp;</TD>" ) ;
		} else {
			out.println ( "<TD bgcolor=\'#f7f7f7\'><a href=\"/servlet/ShowAllOfficialServlet?page=1&name=" + allTeam[loop].getName() + "&upDep=" + allTeam[loop].getUpDepartment() + "\" target=\"detail\">" + allTeam[loop].getName() + "</A></TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getUpDepartment() + "</TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getDevelopField() + "</TD>" ) ;

			loop++ ;
		}
		out.println ( "    </tr>" ) ;
		out.println ( "    <tr>" ) ;
		if ( (allTeam[loop].getName().equals("null")) || (stop==true) ) {
			stop = true ;
			out.println ( "<TD bgcolor=\'#f7f7f7\'>&nbsp;</TD><TD bgcolor=\'#f7f7f7\'>&nbsp;</TD><TD bgcolor=\'#f7f7f7\'>&nbsp;</TD>" ) ;
		} else {
			out.println ( "<TD bgcolor=\'#f7f7f7\'><a href=\"/servlet/ShowAllOfficialServlet?page=1&name=" + allTeam[loop].getName() + "&upDep=" + allTeam[loop].getUpDepartment() + "\" target=\"detail\">" + allTeam[loop].getName() + "</A></TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getUpDepartment() + "</TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getDevelopField() + "</TD>" ) ;

			loop++ ;
		}
		out.println ( "    </tr>" ) ;
		out.println ( "    <tr>" ) ;
		if ( (allTeam[loop].getName().equals("null")) || (stop==true) ) {
			out.println ( "<TD bgcolor=\'#f7f7f7\'>&nbsp;</TD><TD bgcolor=\'#f7f7f7\'>&nbsp;</TD><TD bgcolor=\'#f7f7f7\'>&nbsp;</TD>" ) ;
		} else {
			out.println ( "<TD bgcolor=\'#f7f7f7\'><a href=\"/servlet/ShowAllOfficialServlet?page=1&name=" + allTeam[loop].getName() + "&upDep=" + allTeam[loop].getUpDepartment() + "\" target=\"detail\">" + allTeam[loop].getName() + "</A></TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getUpDepartment() + "</TD>" ) ;
			out.println ( "<TD align=center bgcolor=\'#f7f7f7\'>" + allTeam[loop].getDevelopField() + "</TD>" ) ;
		}
		out.println ( "    </tr>" ) ;		
		out.println ( "</table>" ) ;
		out.println ( "			<!----------------------------------글 리스트보여주는 테이블의 끝-------------------------->" ) ;
		out.println ( "</td></tr></table>" ) ;
		out.println ( "<!----------------------------------글 리스트 보여주는 테이블을 약간 오른쪽으로 하기위한 큰 테이블의 끝 ------->" ) ;
		out.println ( "</td></tr></table></center><br>" ) ;
		
		out.println ( "<table align=center><tr align=center>" ) ;			

		out.println ( "<br>" ) ;
		out.println ( "<CENTER><TABLE width=700 border=0 cellPadding=2 cellSpacing=1>" ) ;
		out.println ( "  <TR><TD align=right>" ) ;
		if ( isSearch ) {
			out.println ( "<form action=\"/servlet/ShowAllTeamServlet\" method=\"GET\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"form\" value=\"form\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"page\" value=\"1\">" ) ;			
			out.println ( "<input type=\"hidden\" name=\"name\" value=\"" + original + "\">" ) ;
			out.println ( "<INPUT type=button name=back value=\"되돌아 가기\" onClick=\"Back_Click()\"></form>" ) ;
		} else {
			out.println ( "<form action=\"/servlet/ShowOneDepartmentServlet?\" method=\"GET\">" ) ;
			out.println ( "<input type=\"hidden\" name=\"property\" value=\"" + name + "\">" ) ;
			out.println ( "<INPUT type=submit name=detail value=\"" + name + " 상세 정보\">&nbsp;&nbsp;&nbsp;&nbsp;</form>" ) ;
		}	
		out.println ( "</TD></TR></TABLE><CENTER>" ) ;
		out.println ( "</body></html>" ) ;
		
		out.close ( ) ;
	}
}