/* 
    ETRI IntraPMS Project
    문서 검색을 위한Servlet

    
*/

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

import com.etri.groupware.*;
import com.etri.groupware.eda.*;

public class EDADocumentBoxServlet extends HttpServlet{

	GroupwareControllerInterface groupwareController = null;
	EDAControllerInterface edaController = null;
	Properties pro=null;
			
	public void init( ServletConfig sc ) throws ServletException{
		super.init(sc);
		
		pro = new Properties();
		pro.put("DriverName","weblogic.jdbc.mssqlserver4.Driver");
		pro.put("DBServer","jdbc:weblogic:mssqlserver4:GWDB@Server:1433");
		pro.put("User","sa");
		pro.put("Password","");
		
		pro.put("OrganizationDBManagerClassName","PandaSoftOrganizationDBManager");
		pro.put("BBSDBManagerClassName","PandaSoftBBSDBManager");
		pro.put("EDADBManagerClassName","PandaSoftEDADBManager");
		pro.put("MailDBManagerClassName","PandaSoftMailDBManager");
		
		try{
			groupwareController = GroupwareController.init( pro );
			System.out.println("그룹웨어 컨트롤러 생성을 마쳤습니다.");
			
			edaController = groupwareController.createEDAController();
			System.out.println("전자결재 컨트롤러 생성도 무사히 마쳤습니다.");	
		}
		catch( Exception e){
			System.out.println( e.toString() );
		}
	}

	public void destroy(){
		System.out.println("EDADocumentBoxServlet Destroy() 호출");
		super.destroy();
		DBConnectionManager.instance.release();
		System.out.println("EDADocumentBoxServlet Destroy() 완료");
	}

/*----------------------------------------------------------------- */
/**
 [메소드이름]: doGet<br>
 [기능]: 문서함을 보여준다.<br>
 [파라미터]: HttpServletRequest req,HttpServletResponse res<br>
 [호출자] : 사용자<br>
 */
/*--------------------------------------------------------------- */	

	public void doGet(HttpServletRequest req,HttpServletResponse res) 
	 throws ServletException,IOException{
	 	System.out.println("GET 함수 시작");
	 		 	
	 	HttpSession session = req.getSession(true);
	 	
		res.setContentType("text/html;charset=edu-kr");
		PrintWriter out = new PrintWriter( new OutputStreamWriter(
		 res.getOutputStream(),"EUC-KR"));
		
		boolean authentication = false;	
		String id = null ;
		String name = null;		

		if((session.isNew())){
			session.invalidate();
			res.sendRedirect("../Login.html");
		}
		else if(session.getValue("Authentication").equals("true")){
			authentication = true;
			id = (String)session.getValue("Id");
			name = (String)session.getValue("Name");
		}
		else{
			session.invalidate();
			res.sendRedirect("../Login.html");
		}
		
		if( authentication ){
			String doGet = req.getParameter("doGet");
			System.out.println("doGet:"+ doGet);
			String listID = req.getParameter("listID");
			System.out.println("listID : " + listID );
			int count = Integer.parseInt(req.getParameter("count"));
			System.out.println("count");
			
			try{
				
				int pageSize = (edaController.loadEDAOption ( name + "(" + id + ")" )).getnumOfItem();
				
				out.println("<html><head>");
				out.println("<FORM METHOD = GET  name=\"form1\" action=\"/servlet/EDADocumentServlet\">");
				out.println("<p align=right><img src=\'../image/우측_기안결재.gif\'></p>");
				ApprovalDocument[] document;
				document = edaController.getDocumentLists( name + "(" + id + ")" , listID );
				if( document.length > 0 ){		
					if(listID.equals(Lists.INGBOX)){
						out.println("<body text=\"black\""+
						 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">"+
						 "<b>결재할 문서함</b></font><br></p>");
						 
						out.println("<table width=600 align=\"center\">");
						out.println("<tr>");
						out.println("<td width=600 align=\"right\">"+
						 "<font size=1 color=black>Page="+ count +
						 "/Total="+document.length+"</font><br></td>");
						out.println("</tr>");
						out.println("</table>");

						out.println("<hr width=600><br>");
						out.println("<div align=\"center\">"+
						 "<table cellpadding=\"2\" "+
						 " width=\"600\" align=\"center\">");
			    			out.println("<tr bgcolor=#c7e4ff>");
			        		out.println("<td width=\"105\" align=\"center\" >"+
			        	 	 "<p align=\"center\"><font size=\"2\" color=\"black\">작성자"+
			        	 	 "</font></td>");
				        	out.println("<td width=\"92\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>문서분류"+
				        	 "</b></font></td>");
				        	out.println("<td width=\"300\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>제목</b>"+
				        	 "</font></td>");
				        	out.println("<td width=\"98\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성일"+
				        	 "</b></font></td>");
				    		out.println("</tr>");
				    	} 
					else if(listID.equals(Lists.COMPLETEBOX)){
						out.println("<body text=\"black\""+
						 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">"+
						 "<b>완료된 문서함</b></font><br></p>");

						out.println("<table width=600 align=\"center\">");
						out.println("<tr>");
						out.println("<td width=600 align=\"right\">"+
						 "<font size=1 color=black>Page="+ count +
						 "/Total="+document.length+"</font><br></td>");
						out.println("</tr>");
						out.println("</table>");
						
						out.println("<hr width=600><br>");
						out.println("<table cellpadding=\"2\" "+
						 " width=\"600\" align=\"center\">");
			    			out.println("<tr bgcolor=#c7e4ff>");
			        		out.println("<td width=\"150\" align=\"center\" >"+
			        	 	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>문서번호"+
			        	 	 "</b></font></td>");
			        		out.println("<td width=\"300\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>제목"+
				        	 "</b></font></td>");
				        	out.println("<td width=\"75\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성일</b>"+
				        	 "</font></td>");
				        	out.println("<td width=\"75\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>완료일"+
				        	 "</b></font></td>");
				    		out.println("</tr>");
				    	}
					else if(listID.equals(Lists.REJECTBOX)){
						out.println("<body text=\"black\""+
						 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">"+
						 "<b>반려된 문서함</b></font><br></p>");
						 
						out.println("<table width=600 align=\"center\">");
						out.println("<tr>");
						out.println("<td width=600 align=\"right\">"+
						 "<font size=1 color=black>Page="+ count +
						 "/Total="+document.length+"</font><br></td>");
						out.println("</tr>");
						out.println("</table>");
						 
						out.println("<hr width=600><br>");
						out.println("<table cellpadding=\"2\" "+
						 " width=\"600\" align=\"center\">");
				    		out.println("<tr bgcolor=#c7e4ff>");
				        	out.println("<td width=150 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>문서번호"+
				        	 "</b></font></td>");
				        	out.println("<td width=300 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>제목"+
				        	 "</b></font></td>");
				        	out.println("<td width=75 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성일</b>"+
				        	 "</font></td>");
				        	out.println("<td width=75 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>반려자"+
				        	 "</b></font></td>");
				    		out.println("</tr>");
					}
					else if(listID.equals(Lists.SUBMITBOX)){
						out.println("<body text=\"black\""+
						 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">"+
						 "<b>진행중인 문서함</b></font><br></p>");
						 
						out.println("<table width=600 align=\"center\">");
						out.println("<tr>");
						out.println("<td width=600 align=\"right\">"+
						 "<font size=1 color=black>Page="+ count +
						 "/Total="+document.length+"</font><br></td>");
						out.println("</tr>");
						out.println("</table>");
						 
						out.println("<hr width=600><br>");
						out.println("<table cellpadding=\"2\" "+
						 " width=\"600\" align=\"center\">");
				    		out.println("<tr bgcolor=#c7e4ff>");
				        	out.println("<td width=150 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>문서번호"+
				        	 "</b></font></td>");
				        	out.println("<td width=300 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>제목"+
				        	 "</b></font></td>");
				        	out.println("<td width=75 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성일</b>"+
				        	 "</font></td>");
				        	out.println("<td width=75 align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>현결재자"+
				        	 "</b></font></td>");
				    		out.println("</tr>");
					}
					else if(listID.equals(Lists.INFORMBOX)){
						out.println("<body text=\"black\""+
						 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">"+
						 "<b>통보온 문서함</b></font><br></p>");
						 
						out.println("<table width=600 align=\"center\">");
						out.println("<tr>");
						out.println("<td width=600 align=\"right\">"+
						 "<font size=1 color=black>Page="+ count +
						 "/Total="+document.length+"</font><br></td>");
						out.println("</tr>");
						out.println("</table>");
						 
						out.println("<hr width=600><br>");
						out.println("<table cellpadding=\"2\" "+
						 " width=\"600\" align=\"center\">");
			    			out.println("<tr bgcolor=#c7e4ff>");
				        	out.println("<td width=\"105\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성자"+
				        	 "</b></font></td>");
				        	out.println("<td width=\"92\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>문서분류"+
				        	 "</b></font></td>");
				        	out.println("<td width=\"300\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>제목</b>"+
				        	 "</font></td>");
				        	out.println("<td width=\"98\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성일"+
				        	 "</b></font></td>");
				    		out.println("</tr>");
					}
					else if(listID.equals(Lists.ABORTBOX)){
						out.println("<body text=\"black\""+
						 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">"+
						 "<b>상신취소함</b></font><br></p>");
						 
						out.println("<table width=600 align=\"center\">");
						out.println("<tr>");
						out.println("<td width=600 align=\"right\">"+
						 "<font size=1 color=black>Page="+ count +
						 "/Total="+document.length+"</font><br></td>");
						out.println("</tr>");
						out.println("</table>");
						 
						out.println("<hr width=600><br>");	
						out.println("<table  cellpadding=\"2\" "+
						 " width=\"600\" align=\"center\">");
			    			out.println("<tr bgcolor=#c7e4ff>");
			        		out.println("<td width=\"150\" align=\"center\" >"+
			        	 	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>문서번호"+
			        	 	 "</b></font></td>");
			        		out.println("<td width=\"300\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>제목"+
				        	 "</b></font></td>");
				        	out.println("<td width=\"75\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성일</b>"+
				        	 "</font></td>");
				        	out.println("<td width=\"75\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>취소일"+
				        	 "</b></font></td>");
				    		out.println("</tr>");
					}
					else if( listID.equals(Lists.PUBLICBOX)){
						out.println("<body text=\"black\""+
						 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">"+
						 "<b>공용 문서함</b></font><br></p>");
						 
						out.println("<table width=600 align=\"center\">");
						out.println("<tr>");
						out.println("<td width=600 align=\"right\">"+
						 "<font size=1 color=black>Page="+ count +
						 "/Total="+document.length+"</font><br></td>");
						out.println("</tr>");
						out.println("</table>");
						 
						out.println("<hr width=600><br>");						 
						out.println("<table cellpadding=\"2\" "+
						 " width=\"600\" align=\"center\">");
						out.println("<tr bgcolor=#c7e4ff>");
			        		out.println("<td width=\"150\" align=\"center\" >"+
			        	 	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>문서번호"+
			        	 	 "</b></font></td>");
			        		out.println("<td width=\"300\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>제목"+
				        	 "</b></font></td>");
				        	out.println("<td width=\"75\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성자</b>"+
				        	 "</font></td>");
				        	out.println("<td width=\"75\" align=\"center\" >"+
				        	 "<p align=\"center\"><font size=\"2\" color=\"black\"><b>작성일"+
				        	 "</b></font></td>");
				    		out.println("</tr>");
				    	}
				    	
				    	String docIDS = document[0].getdocID();
				    	for( int i = 1 ; i < document.length ; i++ )
				    		docIDS = docIDS + "," + document[i].getdocID();
				    	System.out.println("문서 총 갯수:"+ document.length);	
					for(int i = (count - 1 ) * pageSize ; ( i < document.length ) && ( i < ( count * pageSize ) ); i++ ){
						System.out.println( i + "번재 문서 획득.문서 번호 :"+ document[i].getdocID());
						
						document[i].setinitDay( (document[i].getinitDay()).substring(0,10));
						out.println("<tr>");
						if(listID.equals(Lists.INGBOX)){
							System.out.println("작성자 기록 중 ");
						 	StringTokenizer initPerson = new StringTokenizer(document[i].getinitPersonID(),"(");
							System.out.println("작성자:" + document[i].getinitPersonID());
			    				
			    				out.println("<td width=105 align=\"right\" >"+
			        		 	"<p align=\"center\"><font size=2 color=black>"+
			        		 	initPerson.nextToken() + "</font></td>");
	
			  	        		out.println("<td width=92 align=\"center\" >"+
			        			 "<p align=\"center\"><font size=2 color=black>" +
			        			 (document[i].getdocID()).substring(0,4)+"</font></td>");
			        			 
			        		       	System.out.println("문서 Link 기록 중");
			        			out.println("<td width=300 align=\"center\" >"+
			       			 	 "<p align=\"left\"><a href=\"http:/servlet/EDADocumentServlet?count="
			       			  	 +count+"&listID="+listID+"&DocID="+document[i].getdocID()+ 
			       			 	 "&Search=NO&DocIDS="+docIDS+"&position="+i+"&length="+document.length+"\">" +
			       			 	 "<font size=2>&nbsp;" + document[i].gettitle() +"</font></a></p></td>");

    			 				System.out.println("작성일 기록 중 ");		
				        		out.println("<td width=98 align=\"center\" >"+
				        		 "<p align=\"center\"><font size=2 color=black>"+
				        		 document[i].getinitDay() + "</font></td>");
						}
						if(listID.equals(Lists.COMPLETEBOX)){
				        	   	System.out.println("문서 번호 작성 중 .문서 번호 :"+ document[i].getdocID() );
				        	 	out.println("<td width=150 align=\"center\" >"+
			        			 "<p align=\"center\"><font size=2 color=black>" +
			        			 document[i].getdocID() +"</font></td>");

			        		       	System.out.println("문서 Link 기록 중");
			        			out.println("<td width=300 align=\"center\" >"+
			       			 	 "<p align=\"left\"><a href=\"http:/servlet/EDADocumentServlet?count="
			       			  	 +count+"&listID="+listID+"&DocID="+document[i].getdocID()+ /*여기서부터는 debug용 */"&id=" + id + "&name=" + name +
			       			 	 "&Search=NO&DocIDS="+docIDS+"&position="+i+"&length="+document.length+"\">" +
			       			 	 "<font size=2>&nbsp;" + document[i].gettitle() +"</font></a></p></td>");

			        		   	System.out.println("작성 일자 기록 중.작성 일자:" + document[i].getinitDay());
			        			out.println("<td width=75 align=\"center\" >"+
			        		 	 "<p align=\"center\"><font size=2 color=black>"+
			        		 	 document[i].getinitDay() + "</font></td>");
							
							System.out.println("종료일 기록 중");
							document[i].setendDay();
							System.out.println("종료일 :"+ document[i].getendDay());
		
							out.println("<td width=75 align=\"center\" >"+
						 	 "<p align=\"center\"><font size=2 color=black>"+
						 	 (document[i].getendDay()).substring(0,10) +"</font></td>");
						}
						
						if(listID.equals(Lists.REJECTBOX)){
						   	System.out.println("문서 번호 작성 중 .문서 번호 :"+ document[i].getdocID() );
				        	 	out.println("<td width=150 align=\"center\" >"+
			        			 "<p align=\"center\"><font size=2 color=black>" +
			        			 document[i].getdocID() +"</font></td>");

			        		       	System.out.println("문서 Link 기록 중");
			        			out.println("<td width=300 align=\"center\" >"+
			       			 	 "<p align=\"left\"><a href=\"http:/servlet/EDADocumentServlet?count="
			       			  	 +count+"&listID="+listID+"&DocID="+document[i].getdocID()+ /*여기서부터는 debug용 */"&id=" + id + "&name=" + name +
			       			 	 "&Search=NO&DocIDS="+docIDS+"&position="+i+"&length="+document.length+"\">" +
			       			 	 "<font size=2>&nbsp;" + document[i].gettitle() +"</font></a></p></td>");

			 				System.out.println("작성일 기록 중 ");		
				        		out.println("<td width=75 align=\"center\" >"+
				        		 "<p align=\"center\"><font size=2 color=black>"+
				        		 document[i].getinitDay() + "</font></td>");
				        		 
							document[i].setreturnPerson();
							System.out.println("반려자 작성 중 .반려자 :"+ document[i].getreturnPerson());
							StringTokenizer rejectPerson = new StringTokenizer( document[i].getreturnPerson() ,"(");
							
							out.println("<td width=75 align=\"center\" >"+
							 "<p align=\"center\"><font size=2 color=black>"+
							 rejectPerson.nextToken() + "</font></td>");
						}
				        	if(listID.equals(Lists.SUBMITBOX)){	 
				        	   	System.out.println("문서 번호 작성 중 .문서 번호 :"+ document[i].getdocID() );
				        	 	out.println("<td width=150 align=\"center\" >"+
			        			 "<p align=\"center\"><font size=2 color=black>" +
			        			 document[i].getdocID() +"</font></td>");

			        		       	System.out.println("문서 Link 기록 중");
			        			out.println("<td width=300 align=\"center\" >"+
			       			 	 "<p align=\"left\"><a href=\"http:/servlet/EDADocumentServlet?count="
			       			  	 +count+"&listID="+listID+"&DocID="+document[i].getdocID()+ /*여기서부터는 debug용 */"&id=" + id + "&name=" + name +
			       			 	 "&Search=NO&DocIDS="+docIDS+"&position="+i+"&length="+document.length+"\">" +
			       			 	 "<font size=2>&nbsp;" + document[i].gettitle() +"</font></a></p></td>");

			 				System.out.println("작성일 기록 중 ");		
				        		out.println("<td width=75 align=\"center\" >"+
				        		 "<p align=\"center\"><font size=2 color=black>"+
				        		 document[i].getinitDay() + "</font></td>");

							document[i].setcurrentPerson();						
							System.out.println("현 결재자 작성 중.현 결재자 : "+ document[i].getcurrentPerson());
							StringTokenizer currPerson = new StringTokenizer( document[i].getcurrentPerson(),"(");
							out.println("<td width=75 align=\"center\" >"+
							 "<p align=\"center\"><font size=2 color=black>"+
							 currPerson.nextToken() + "</font></td>");
						}
						
						if(listID.equals(Lists.INFORMBOX)){
					   	   	System.out.println("작성자 기록 중 ");
						 	StringTokenizer initPerson = new StringTokenizer(document[i].getinitPersonID(),"(");
							System.out.println("작성자:" + document[i].getinitPersonID());
			    				
			    				out.println("<td width=105 align=\"right\" >"+
			        		 	"<p align=\"center\"><font size=2 color=black>"+
			        		 	initPerson.nextToken() + "</font></td>");
	
			  	        		out.println("<td width=92 align=\"center\" >"+
			        			 "<p align=\"center\"><font size=2 color=black>" +
			        			 (document[i].getdocID()).substring(0,4)+"</font></td>");

			        		       	System.out.println("문서 Link 기록 중");
			        			out.println("<td width=300 align=\"center\" >"+
			       			 	 "<p align=\"left\"><a href=\"http:/servlet/EDADocumentServlet?count="
			       			  	 +count+"&listID="+listID+"&DocID="+document[i].getdocID()+ /*여기서부터는 debug용 */"&id=" + id + "&name=" + name +
			       			 	 "&Search=NO&DocIDS="+docIDS+"&position="+i+"&length="+document.length+"\">" +
			       			 	 "<font size=2>&nbsp;" + document[i].gettitle() +"</font></a></p></td>");

			 				System.out.println("작성일 기록 중 ");		
				        		out.println("<td width=98 align=\"center\" >"+
				        		 "<p align=\"center\"><font size=2 color=black>"+
				        		 document[i].getinitDay() + "</font></td>");
						}
						
						if(listID.equals(Lists.ABORTBOX)){
				        	   	System.out.println("문서 번호 작성 중 .문서 번호 :"+ document[i].getdocID() );
				        	 	out.println("<td width=150 align=\"center\" >"+
			        			 "<p align=\"center\"><font size=2 color=black>" +
			        			 document[i].getdocID() +"</font></td>");

			        		       	System.out.println("문서 Link 기록 중");
			        			out.println("<td width=300 align=\"center\" >"+
			       			 	 "<p align=\"left\"><a href=\"http:/servlet/EDADocumentServlet?count="
			       			  	 +count+"&listID="+listID+"&DocID="+document[i].getdocID()+ 
			       			 	 "&Search=NO&DocIDS="+docIDS+"&position="+i+"&length="+document.length+"\">" +
			       			 	 "<font size=2>&nbsp;" + document[i].gettitle() +"</font></a></p></td>");

			        		   	System.out.println("작성 일자 기록 중.작성 일자:" + document[i].getinitDay());
			        			out.println("<td width=75 align=\"center\" >"+
			        		 	 "<p align=\"center\"><font size=2 color=black>"+
			        		 	 document[i].getinitDay() + "</font></td>");

							System.out.println("상신 취소일 작성 중");
							out.println("<td width=75 align=\"center\" >"+
							 "<p align=\"center\"><font size=2 color=black>"+
							 (((ApprovalCourse)document[i].getapprovalCourse(0)).getworkDate()).substring(0,10) + "</font></td>"); 
						}
						
						if(listID.equals(Lists.PUBLICBOX)){
				        	   	System.out.println("문서 번호 작성 중 .문서 번호 :"+ document[i].getdocID() );
				        	 	out.println("<td width=150 align=\"center\" >"+
			        			 "<p align=\"center\"><font size=2 color=black>" +
			        			 document[i].getdocID() +"</font></td>");
							
					        	System.out.println("문서 Link 기록 중");
				        		out.println("<td width=300 align=\"center\" >"+
				       			 "<p align=\"left\"><a href=\"http:/servlet/EDADocumentServlet?count="
				       			  +count+"&listID="+listID+"&DocID="+document[i].getdocID()+ 
				       			 "&Search=NO&DocIDS="+docIDS+"&position="+i+"&length="+document.length+"\">" +
				       			 "<font size=2>&nbsp;" + document[i].gettitle() +"</font></a></p></td>");

							System.out.println("공용 문서함에서 작성자 기록 중 ");
						 	StringTokenizer initPerson = new StringTokenizer(document[i].getinitPersonID(),"(");							
			        			out.println("<td width=75 align=\"center\" >"+
			        		 	 "<p align=\"center\"><font size=2 color=black>"+
			        		 	 initPerson.nextToken() + "</font></td>");

			 				System.out.println("작성일 기록 중 ");		
				        		out.println("<td width=75 align=\"center\" >"+
				        		 "<p align=\"center\"><font size=2 color=black>"+
				        		 document[i].getinitDay() + "</font></td>");
						}
						out.println("</tr>");
					}	
			   	
					out.println("</table>");
					out.println("<div align=\"center\"><table border=\"0\">");
					out.println("<tr>");
					
					int i = ( count-1 ) / 5;
					int j = ( i * 5) + 5;
					
					if( count>=6 ){
						out.println("<td width=\"30\"><p align=\"center\">"+
						 "<a href= \"http:/servlet/EDADocumentBoxServlet?count="
				  	 	 + (i*5) + "&listID="+ listID + 
				 	 	 "&doGet=YES\">[prev]</a></p></td>");
						System.out.println("Prev인쇄");//debug
					}

					for( i *= 5 ;( i * pageSize < document.length ) && ( i < j ) ; i++){
						out.println("<td width=\"30\"><p align=\"center\">"+
				 	 	 "<a href=\"http:/servlet/EDADocumentBoxServlet?count="
				  	 	 + (i+1) + "&listID=" + listID + 
				 	 	 "&doGet=YES\">[" + ( i + 1) + "]</a></p></td>");
						//System.out.println( (i+1)+"Page인쇄");//debug
					}
					if( j*pageSize <  document.length ){
						out.println("<td width=\"30\"><p align=\"center\">"+
				 	 	 "<a href= \"http:/servlet/EDADocumentBoxServlet?count="
				 	 	 + (j+1) + "&listID="+ listID +
				 	 	 "&doGet=YES\">[next]</a></p></td>");
				 		System.out.println("next인쇄");
					}
					out.println("</tr>");
					out.println("</table>");
					out.println("<table order=\"0\" width=\"600\">");
					out.println("<td>");
					out.println("<p align=\"right\">"+
		 	 		 "<a href=\"http:/servlet/EDASearchInputServlet?count="
			 	 	 + count + "&listID=" + listID +
			 	 	 "\"><img src='/image/search.gif' border=0 alt='검색'></a></p></td>");
			 	 	out.println("</table>");
				}
				else{
					out.println("<body text=\"black\""+
					 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
					if( listID.equals( Lists.COMPLETEBOX ) )
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
					 	 "<b>완료된 문서함</b></font></p>");
					else if( listID.equals( Lists.INGBOX ) )
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
						 "<b>결재할 문서함</b></font></p>");
					else if( listID.equals( Lists.REJECTBOX ) )
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
						 "<b>반려된 문서함</b></font></p>");
					else if( listID.equals( Lists.SUBMITBOX ) )
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
						 "<b>진행중인 문서함</b></font></p>");
					else if( listID.equals( Lists.INFORMBOX ) )
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
						 "<b>통보온 문서함</b></font></p>");
					else if( listID.equals( Lists.ABORTBOX ) )
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
						 "<b>상신 취소함</b></font></p>");
					else if( listID.equals( Lists.PUBLICBOX ) )
						out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
						 "<b>공용 문서함</b></font></p>");
						
					out.println("<p align=\"center\"><hr width=600><br>");
					out.println("<p align=\"center\">문서함에 문서가 없습니다.<br>");
				}
				System.out.println("HTML작성완료");//debug
				out.println("</p>");
				out.println("</body>");
				out.println("</form>");
				out.println("</html>");
			}
			catch( Exception e){
				out.println("<body text=\"black\""+
				 "link=\"blue\" vlink=\"purple\" alink=\"red\">");
				if( listID.equals( Lists.COMPLETEBOX ) )
					out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
				 	 "<b>완료된 문서함</b></font></p>");
				else if( listID.equals( Lists.INGBOX ) )
					out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
					 "<b>결재할 문서함</b></font></p>");
				else if( listID.equals( Lists.REJECTBOX ) )
					out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
					 "<b>반려된 문서함</b></font></p>");
				else if( listID.equals( Lists.SUBMITBOX ) )
					out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
					 "<b>진행중인 문서함</b></font></p>");
				else if( listID.equals( Lists.INFORMBOX ) )
					out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
					 "<b>통보온 문서함</b></font></p>");
				else if( listID.equals( Lists.ABORTBOX ) )
					out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
					 "<b>상신 취소함</b></font></p>");
				else if( listID.equals( Lists.PUBLICBOX ) )
					out.println("<p align=\"center\"><font size=\"4\" color=\"gray\">" +
					 "<b>공용 문서함</b></font></p>");
				out.println("<p align=\"center\"><hr width=600><br>");
				out.println("<p align=\"center\">문서함을 검색하는 중 에러가 발생했습니다.<br>");
				out.println("<p align=\"center\">" +  e.toString() +"<br>");
			}				
		}
		else{
			//사용자 인증에 실패했습니다.
			res.sendRedirect("../Login.html");
		}		
		out.close();
		
	}
}