* web.xml 파일에 추가될 내용
<servlet>
<servlet-name>PyServlet</servlet-name>
<servlet-class>org.python.util.PyServlet</servlet-class>
<init-param>
<param-name>python/home</param-name>
<param-value>/opt/usr/local/jython2.5.3</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>PyServlet</servlet-name>
<url-pattern>*.py</url-pattern>
</servlet-mapping>
* 수정 전 PyServlet: enter.py
You have played this game %s times.\n
""" % ( request.getParameter("thing"), counter) self.doGet(request, response) def doGet(self, request, response): response.contentType = "text/html; charset=utf-8" out = response.outputStream print >> out, """Enter a string:
You have played this game %s times.\n
""" % ( request.getParameter("thing").encode("utf-8"), counter) self.doGet(request, response) def doGet(self, request, response): response.contentType = "text/html; charset=utf-8" out = response.outputStream print >> out, """Enter a string:
* Mac OS X Lion에서 Tomcat 7 & Jython 2.5.3을 사용하여 enter.py를 실행한 장면
'프로그래밍 > Jytthon' 카테고리의 다른 글
Jython 실행 후 환경변수 JAVA_HOME 이 변경되는 현상 (0) | 2013.01.20 |
---|---|
Jython 2.5.2 에서 한글 인코딩 문제 (0) | 2011.04.07 |