U E D R , A S I H C RSS

Project Prometheus/Cook Book


1. Python —„œ˜ •œธ€ ‚ฌšฉ

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 ๋ฅผ šฉ•  ˆ˜๋„ žˆ๋‹ค. ๋˜๋Š” Seminar: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
    ‹ˆœ•˜ง€๋งŒ ๋งคšฐ Žธ๋ฆฌ•œ ƒ€ด๋จธ. ƒœŠคฌ ๋ฐ”—„œ ๋‚จ€ ‹œ„„ ™•ฐ€๋Šฅ

6. HTTP Protocol

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" ... ‹œผ๋กœ ๋‚ ˜จ๋‹ค.

‹Œ€ Python „ šฉ, Cookie, GET/POST ๋ณ€ˆ˜๋“ค„ „šด๋’ค •ด๋‹‚ฌŠธ˜ ฒฐณผ๋ฌผ„ ‡„•˜๋Š” †ŒŠค.
cookieSend.py

11. Resin

12. default root  •˜ & ฌŠธ ˆ˜ •

root ๋””๋ ‰† ๋ฆฌ๋Š” <doc-dir> ƒœธ๋ถ€๋ถ„„, port ๋Š” <http port='____'> ๋ถ€๋ถ„„ ˆ˜ ••œ‹ค.
‘˜‹ค <http-server> ƒœ•˜œ„— žˆ๋‹ค.

13. default utility

resin —„œ ™ˆ ๋””๋ ‰† ๋ฆฌ๋ฅผ ๋ณ€ฒฝ•˜ฑฐ๋‚˜ resin ‹–‰๋ •Œ ธฐ๋ณธ œผ๋กœ ƒธฐ๋Š” ๋””๋ ‰† ๋ฆฌ๋“ค(example ๋“ฑ)žˆ๋‹ค.
ด๋Š” <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 ฝ”๋“œ ž‘„ผ๋ฐ˜ ˆœ„œ

  1. Context - environment –ป 
  2. environment ๋ณ€ˆ˜๋ฅผ ฑฐ๋กœ Data Source –ป 
  3. Data Source ๋ฅผ ฑฐ๋กœ Connection –ป  Connection „ šฉ.
  4. Connection ฒด๋กœ Statement ฒด๋ฅผ –ป 
  5. Statement ฒด๋กœ SQL ˆ˜–‰. ResultSet ฒด –ปธฐ.
  6. 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 Œ€ ผ๋™

17. ETC

18. ZeroPageServer —„œ UnitTest

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)
  • Ant —„œ JUnit „ ‹–‰‹œ‚ค๋Š” ๋ฐฉ๋ฒ•žˆ๋‹  •œ‹ค. ถ”›„ •Œ•„๋ณผฒƒ.~!

19. •ˆ „•˜ฒŒ UI ˆ˜ ••˜ธฐ

Ant ๋ฅผ šฉ•˜๋ฉด ๋œ‹ค. Ant ˜ ฒฝšฐ ปดŒŒผ & ๋ฐฐฌ• •Œ ˆ˜ •๋œ ™”ผ๋งŒ ๋ฎ–ด“ฐธฐ๋ฅผ •œ‹ค. CVS & Ant กฐ•ด๋ฉด •ฒฐด๋ƒฐ.


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:24:05
Processing time 0.0248 sec