Jython 을 이용한 Servlet 코드 작성하기.
http://jywiki.sourceforge.net/ - 다양한 예제들. Image, JDBC 연동 등.
Resin 에서의 Setting ¶
<web-app> 항목에 다음을 추가
~cpp <servlet> <servlet-name>PyServlet</servlet-name> <servlet-class>org.python.util.PyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>PyServlet</servlet-name> <url-pattern>*.py</url-pattern> </servlet-mapping>요즈음(resin 3.08 기준)에는 이렇게 쓴다.
~cpp <web-app ..> . <servlet servlet-name="PyServlet" servlet-class="org.python.util.PyServlet"/> <servlet-mapping url-pattern="*.py" servlet-name="PyServlet"/> . . </web-app>
resin/lib 디렉토리에 jython.jar 화일을 복사해준다.
예제 코드.
~cpp from javax.servlet.http import HttpServlet class test(HttpServlet): def doGet(self, req, res): res.setContentType("text/html") out = res.getOutputStream() out.println("Testing...") print >>out, "" print >>out, "" print >>out, "Hello World..." print >>out, "" print >>out, "" out.close() return작동이 되면 성공.~