segioHelp(All)/쎄지오도움말 4.0(ko)



5.4 확장개발-JSP
인쇄
 
2009-07-09 19:05:10
조회:39764
답글지움수정 아랫글 목록 윗글

 

5.4 확장개발-JSP


SEGIO에서는 JSP를 구동하기 위해 톰캣(Tomcat)을 연동하여 JSP 실행환경을 구성한 후 사용할 수 있습니다.

 

1) 개요

  - JSP 연동은 SEGIO 4.0 Update1이상 버전에서만 지원이 가능하며  jsp 파일은 확장자가 *.jsp ,  *.do  일경우에만 동작합니다.

  - JSP파싱 부분을 tomcat에게 위임하는 형태로 동작하기 때문에 반드시 tomcat이 서버에 설치되어야 합니다.
  - SEGIO 데몬은 80Port로 동작하고 있고 tomcat은 8080으로 설치된 것으로 가정하고 본 매뉴얼은 설명됩니다.

2) 서버설정

 가) SEGIO 설정

     ㄱ) 시스템 설정:  /etc/shttpd/conf/shttpd.conf파일을 다음과 같이 JSP PORT를 추가합니다.
 
     
          * 이어서 쎄지오 웹데몬을 재실행합니다. (명령어 service shttpd restart )
 
     ㄴ) 웹 설정:  관리자 아이디(예: sysop)으로  로그인한 뒤 아래 그림과 같이 관리도구-> 환경설정 -> 선택사항 -> jsp항목을 체크합니다.
 

 

 

     나) tomcat 설정

- 톰갯을 다운 로드 받는다 ( http://apache.yongbok.net/tomcat/ )
- tomcat 설치 위치 : /home/tomcat6
- /home/tomcat6/conf/server.xml 파일을 열어 다음과 같이 실행Port를 8080으로 설정합니다.
<C0nnector port="8080" protocol="HTTP/1.1"
                         connecti0nTimeout="20000"
                         redirectPort="8443" />

 

- tomcat의 Document-Root를 /home/segio/cell000/folder/html로 설정합니다.
- /home/tomcat6/conf/server.xml에서 다음과 같은 항목을 수정하면 됩니다.
<Host name="localhost" appBase="/home/segio/cell000/folder/html"
              unpackWARs="true" autoDeploy="true"
              xmlValidati0n="false" xmlNamespaceAware="false">
             <C0ntext path="" docBase="." reloadable="true" />
 
</Host>
 
- 설정 완료 후엔 tomcat을 재실행합니다. 명령어는 다음과 같습니다.
- 서비스 중단 : /home/tomcat6/bin/shutdown.sh
- 서비스 시작 : /home/tomcat6/bin/startup.sh
 

 3) 인증연동

 - 로그인 시에 cookie로 전달되는 항목입니다.

변수명 이름 내 용
COBEE_USERNAME

사용자 별명

- 로그인한 사용자의 별명
COBEE_USER

사용자 아이디

- 로그인한 사용자의 아이디
COBEE_REALNAME

사용자의 실명

- 로그인한 사용자의 실명
COBEE_USERPERM

사용자 권한

- 사용자의 현재 사이트의 권한
- COBEE_USERPERM 값이 owner이면 사이트 소유자임
- owner는 모든 권한을 가짐
COBEE_USERLEVEL

사용자 등급

- 사용자의 등급 0 ~ 9 등급으로 나누어짐
- 등급별 권한의 제한은 없음
- 사용자 그룹을 구분하기 위해 사용

 

- 다음은 인증 예제 소스입니다.

<%@ page c0ntentType="text/html; charset=utf-8"%>

 <%

Cookie cookies[] = request.getCookies();

sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();

for (int i=0; i < cookies.length; i++)

{

String name = cookies[i].getName();

String value = cookies[i].getValue();

int vlen=value.length();

if((vlen=vlen%3) > 0 ){

for(;vlen-->0;)value=value+"=";

}

if(name.indexOf("COBEE_") != -1)

{

byte[] c0nvert=decoder.decodeBuffer(value);

String new_value=new String(convert);

out.println(name + " : " + new_value + "<br/>");

}

}

%>

 

 

- 로그인 뒤 auth_exam.jsp 실행결과 화면입니다.

 

4) DB 연동(PostgreSQL)

  가)  JDBC 드라이버 설치

 

     ➀  jdbc 다운로드합니다.( 다운로드 URL: http://jdbc.postgresql.org/download.html)

     ➁  jdbc 설치 : 다운로드 받은 postgresql-9.0-801.jdbc4.jar 파일을 /home/tomcat6/lib 디렉토리에 업로드합니다.

     ➂ tomcat을 재시작합니다. 

  나) DB 연동 예제

 

<%@ page c0ntentType="text/html; charset=utf-8" %>

<%@ page import="java.sql.*"%>

<html>

<head>

</head>

<body>

<table border="1">

<tr>

<td>아이디</td>

<td>별명</td>

<td>실명</td>

</tr>

<%

Class.forName("org.postgresql.Driver");

String strC0nn="jdbc:postgresql://localhost/cell_000" +"?user=segio&password=segio";

Connecti0n c0nn = DriverManager.getConnection(strConn);

Statement stmt = conn.createStatement();

 

String strSql = "SELECT * FROM user_info ";

ResultSet rs = stmt.executeQuery(strSql);

while(rs.next())

{

String uid= rs.getString("uid");

String uname= rs.getString("uname");

String rname= rs.getString("rname");

%>

<tr>

<td><%=uid%></td>

<td><%=uname%></td>

<td><%=rname%></td>

</tr>

<%

}

conn.close();

%>

</table>

 

</body>

</html>

 

답글지움수정인쇄 아랫글 목록 윗글
댓글달기