ProjectPrometheus ์ค ๋๋๋งํ Tip ๋ค์ด๋ ๊ธฐํ ์ฝ๋ ์ด๋์๋ค ๋ฑ๋ฑ.
Contents
- 1. Python ์์์ ํ๊ธ ์ฌ์ฉ
- 2. java regular expression
- 3. servlet ์์ ํ๊ธ ์ถ๋ ฅ
- 4. ์ฐ๊ธฐ ์ข์ ํ์ด๋จธ
- 5. ISBN ์ด๋?
- 6. HTTP Protocol
- 7. HTTP GET, POST ๋๊ธฐ๊ธฐ
- 8. HttpUrlConnection ์์ GET,POST ๋๊ธธ๋ ์ฃผ์์ฌํญ
- 9. GET, POST ์ธ์์ ๋ด์ฉ์ค ํ๊ธ์ ๋ฐ์๋ ์ฃผ์ ์ฌํญ
- 10. HTTP Cookie ๋๊ธฐ๊ธฐ
- 11. Resin
- 12. default root ์ ์ & ํฌํธ ์์
- 13. default utility
- 14. Resin ์์ DB POOL Setting
- 15. Resin ์ NT,2000 ์ Service ๋ก ๋ฑ๋ก
- 16. JNDI๋ก resin์์ JDBC ์ฝ๋ ์์ฑ ์ผ๋ฐ์ ์ธ ์์
- 17. ETC
- 18. ZeroPageServer ์์ UnitTest
- 19. ์์ ํ๊ฒ UI ์์ ํ๊ธฐ
2. java regular expression ¶
~cpp String find = "(http|https)+://([^ \t\n<>()"]+)" // ํจํด ์ค์ Pattern pattern = Pattern.compile( find ); // ํจํด ์ปดํ์ผ Matcher matcher = pattern.matcher( html ); // ํจํด ์ฐพ๊ธฐ matcher.group(1); // ์ฌ์ฉ (๊ต์ฒดํ๊ฑฐ๋ ์ฌ๋ฌ๊ฐ์ง ํ ์ ์์)
regular expression ํจํด์ ์ ์ํ๊ธฐ ์ํด์ Komodo ๋ฅผ ์ด์ฉํ ์๋ ์๋ค. ๋๋
TddRegularExpression์ ์๋ํด๋ณด๋ ๊ฒ๋ ์ข๋ค. 1002 ๋ Python Interpreter ๋ฅผ ์ด์ฉ, ํํ์์ ์ฐพ์๋๋ค.

3. servlet ์์ ํ๊ธ ์ถ๋ ฅ ¶
~cpp setContentType
์์ charset ์ euc-kr ๋ฅผ ์ถ๊ฐํด์ค๋ค.~cpp public class HelloWorldApp extends HttpServlet { protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { httpServletResponse.setContentType("text/html; charset=euc-kr"); PrintWriter out = httpServletResponse.getWriter(); out.println("<HTML> " + "ํ๊ธ ํ ์คํธ..." + "</HTML>"); } }
4. ์ฐ๊ธฐ ์ข์ ํ์ด๋จธ ¶
๋ฌผ๋ฆฌ์ ์ธ ๋ชจ๋์๊ณ๊ฐ ์์ ๊ฒฝ์ฐ ์ฌ์ฉํ ๋งํ ๋ชจ๋์๊ณ ์ํํธ์จ์ด
- ๋ฉํฐ ํ์ด๋จธ http://www.programming.de/cpp/timer.zip
๋์์ 10๊ฐ์ ํ์ด๋จธ ์ค์ ๊ฐ๋ฅ. ์นด์ดํธ ๋ค์ด, ์นด์ดํธ ์ ๊ฐ๋ฅ. ๋ฉ์ท๋ค๊ฐ ํ๋ก๊ทธ๋จ์ ๋ค์ ์์ํ ๋ ์ง๋ ์๊ฐ์์ resume ๊ฐ๋ฅ. ๋จ, ๋ฉ๋ชจ๋ฆฌ ๋์ ๋ฒ๊ทธ๊ฐ ์๋ค.
- ๋ง์ดํฌ๋ก ์๊ทธ ํ์ด๋จธ http://users.informatik.fh-hamburg.de/~rohde_i/eggtimer/mr-egg-z.zip
๋จ์ํ์ง๋ง ๋งค์ฐ ํธ๋ฆฌํ ํ์ด๋จธ. ํ์คํฌ ๋ฐ์์ ๋จ์ ์๊ฐ์ ํ์ธ ๊ฐ๋ฅ
7. HTTP GET, POST ๋๊ธฐ๊ธฐ ¶
Python ์์๋ urllib ์ httplib ๋ฅผ ์ด์ฉํ๋ค. Python document ์ httplib - examples ๋ฅผ ์ฐธ์กฐํ๋ฉด GET ์ ์์ POST ์ ์๊ฐ ๋์จ๋ค.
Java ์์๋ HttpURLConnection ์ ์ด์ฉํ๋ค. ๊ด๋ จ ์ฝ๋๋ http://www.javafaq.nu/tips/servlets/index.shtml ๋ฅผ ์ฐธ์กฐ.
~cpp Connection.setRequestProperty("Content-Type", "text/plain");
8. HttpUrlConnection ์์ GET,POST ๋๊ธธ๋ ์ฃผ์์ฌํญ ¶
Python ์์์ string.urlencode ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก GET,POST ๋ก ๋๊ธฐ๊ธฐ ์ ํ๋ผ๋ฉํฐ์ ๋ํด URL Encoding ์ด ํ์ํ๋ค. URLEncoder ๋ผ๋ ํด๋์ค๋ฅผ ์ด์ฉํ๋ฉด ๋๋ค.
~cpp import java.net.URLEncoder; . . . URLEncoder.encode (paramString, "UTF-8");
9. GET, POST ์ธ์์ ๋ด์ฉ์ค ํ๊ธ์ ๋ฐ์๋ ์ฃผ์ ์ฌํญ ¶
~cpp protected void service( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //super.service(request, response); response.setContentType("text/html; charset=euc-kr"); request.setCharacterEncoding("KSC5601"); String serviceName = (String) request.getParameter("service");
getParameter ๊ฐ ํธ์ถ๋๊ธฐ ์ ์ request์ ์ธ์ฝ๋ฉ์ด ์ธํ
๋์ด์ผ ํ๋ค. ํ์ฌ Prometheus์ Controller์ ๊ฒฝ์ฐ service ์ ๋ช
์ ๋ณด๊ณ ๊ฐ๊ฐ์ ์๋น์ค์๊ฒ ์คํ ๊ถํ์ ๋๊ธฐ๋๋ฐ, ๊ฐ์ฅ ์ฒ์์ request์ characterEncoding ์ ์ธํ
ํด์ผ ํ๋ค. ์ฐจํ JSP/Servlet ์ปจํ
์ด๋๋ค์ ์
๊ทธ๋ ์ด๋ ๋์ด์ผ ํ ๋ด์ฉ์ผ๋ก ์๊ฐ๋จ ์์ธํ ๋ด์ฉ์ http://javaservice.net/~java/bbs/read.cgi?m=appserver&b=engine&c=r_p&n=957572615 ์ฐธ๊ณ
10. HTTP Cookie ๋๊ธฐ๊ธฐ ¶
Cookie ๋ ๋ณด๋ด๋์ชฝ HTTP Protocol ์ Header ๋ถ๋ถ์ 'Cookie: a=1; b=2; c=3' ์์ผ๋ก ์ฐ์ฌ์ง๋ค.
๋ฐ๋์ชฝ์์๋ "Set-Cookie: a=10" ... ์์ผ๋ก ๋ ๋ผ์จ๋ค.
๋ฐ๋์ชฝ์์๋ "Set-Cookie: a=10" ... ์์ผ๋ก ๋ ๋ผ์จ๋ค.
๋ค์์ Python ์ ์ด์ฉ, Cookie, GET/POST ๋ณ์๋ค์ ์ฑ์ด๋ค ํด๋น ์ฌ์ดํธ์ ๊ฒฐ๊ณผ๋ฌผ์ ์ธ์ํ๋ ์์ค.
cookieSend.py
cookieSend.py
12. default root ์ ์ & ํฌํธ ์์ ¶
root ๋๋ ํ ๋ฆฌ๋ <doc-dir> ํ๊ทธ๋ถ๋ถ์, port ๋ <http port='____'> ๋ถ๋ถ์ ์์ ํ๋ค.
๋ ๋ค <http-server> ํ๊ทธ ํ์์ ์๋ค.
๋ ๋ค <http-server> ํ๊ทธ ํ์์ ์๋ค.
13. default utility ¶
resin ์์ ํ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ณ๊ฒฝํ๊ฑฐ๋ resin ์ด ์คํ๋ ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์๊ธฐ๋ ๋๋ ํ ๋ฆฌ๋ค(example ๋ฑ)์ด ์๋ค.
์ด๋ <web-app> ๋ผ๋ ํ๊ทธ๋ก ์ ์๋์ด์๋ค. ์ญ์ ํ๊ณ ์ถ๋ค๋ฉด '/' ์ธ์ ๋ค๋ฅธ web-app์ ๋ฑ๋ก๋ ๊ฒ๋ค์ ์ญ์ ํด์ฃผ๋ฉด ๋๋ค.
์ด๋ <web-app> ๋ผ๋ ํ๊ทธ๋ก ์ ์๋์ด์๋ค. ์ญ์ ํ๊ณ ์ถ๋ค๋ฉด '/' ์ธ์ ๋ค๋ฅธ web-app์ ๋ฑ๋ก๋ ๊ฒ๋ค์ ์ญ์ ํด์ฃผ๋ฉด ๋๋ค.
14. Resin ์์ DB POOL Setting ¶
resin.conf ์ ๋ค์์ ์
ํ
ํด์ค๋ค. (<caucho.com> ํ๊ทธ ์์ชฝ์ ์ฝ์
)
~cpp <resource-ref> <res-ref-name>jdbc/'reference ์ด๋ฆ'</res-ref-name> <res-type>javax.sql.DataSource</res-type> <init-param driver-name="org.gjt.mm.mysql.Driver ์์ผ๋ก ๋๋ผ์ด๋ฒ ์ด๋ฆ"/> <init-param url="jdbc:mysql://์๋ฒ์ฃผ์:์๋ฒIP/reference ์ด๋ฆ"/> <init-param user="DB ์ฌ์ฉ์ ID"/> <init-param password="DB ์ฌ์ฉ์ Password"/> <init-param max-connections="20"/> <init-param enable-transaction="false"/> </resource-ref>
15. Resin ์ NT,2000 ์ Service ๋ก ๋ฑ๋ก ¶
resin ์ ์คํํ ๋ ๋ค์๊ณผ ๊ฐ์ด ์คํ
~cpp httpd -install๊ทธ๋ฆฌ๊ณ , ์ ์ดํ-๊ด๋ฆฌ๋๊ตฌ-์๋น์ค ์์ resin web server ์๋น์ค๋ฅผ ์์ ์ํจ๋ค.
16. JNDI๋ก resin์์ JDBC ์ฝ๋ ์์ฑ ์ผ๋ฐ์ ์ธ ์์ ¶
- Context - environment ์ป๊ณ
- environment ๋ณ์๋ฅผ ๊ทผ๊ฑฐ๋ก Data Source ์ป๊ณ
- Data Source ๋ฅผ ๊ทผ๊ฑฐ๋ก Connection ์ป๊ณ Connection ์ ์ด์ฉ.
- Connection ๊ฐ์ฒด๋ก Statement ๊ฐ์ฒด๋ฅผ ์ป๊ณ
- Statement ๊ฐ์ฒด๋ก SQL ์ํ. ResultSet ๊ฐ์ฒด ์ป๊ธฐ.
- ResultSet ๊ฐ์ฒด ์ด์ฉํ๊ธฐ.
~cpp Context env = ( Context )( new InitialContext().lookup( "java:comp/env" ) ); DataSource source = ( DataSource )( env.lookup( "jdbc/zeropage" ) ); conn = source.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("......... some query statement ..................."); while (rs.next()) { rs.getString(1); // ์์์ ๋ฐ๋ผ.. ์ฒซ๋ฒ์งธ : 1๋ฒ... . . . }
ZeroPageServer ์น ํ๋ก๊ทธ๋จ์ ๋ง๋ค์ด์ ๋ฏธ๋ฆฌ ์ฝ์ด๋ณผ ์์ค๋ฅผ ์ฃผ์ ์ ์ฐํ์๊ฒ ๊ฐ์ฌ๋๋ฆฌ๋ฉฐ~! ํ ๋ํ์
resin ์ ํ & JDBC ์ ๊ทผ ๋ฐฉ๋ฒ ํ๋ฐฉ์ ๋์์ด์ฌ..~ -- PP ํ ์ผ๋
resin ์ ํ & JDBC ์ ๊ทผ ๋ฐฉ๋ฒ ํ๋ฐฉ์ ๋์์ด์ฌ..~ -- PP ํ ์ผ๋
18. ZeroPageServer ์์ UnitTest ¶
build_zpLocal.xml ( .../Prometheus/bin ์ ๋น๋ํ๋ ์คํฌ๋ฆฝํธ ) ๋ฅผ ์ด์ฉ, ์คํ๋๋ ์์น์ ๊ด๊ณ์๋ ๊ณณ์ ์ผ๋จ ์ปดํ์ผ์ ํ๊ณ , ํ
์คํธ๋ฅผ ๋๋ฆฌ๊ฒ ํ๋ค.
~cpp .../Prometheus$ ant -buildfile build_zpLocal.xml .../Prometheus$ java -cp "$CLASSPATH:./bin" junit.textui.TestRunner org.zeropage.prometheus.test.AllAllTests ......................................... ............................... Time: 189.444 OK (72 tests)