Dear Rachmat ,  

Step 1 - Check first if the Jyhton is working fine at console prompt, type: Jython and CTRL Z. If  O.K., proceed with step 2.
 
Step 2 - Configure the file web.xml - see samples below and start the web application server (like Jetty, or  IBM WebShpere-CE or others):  

web.xml tested under the Jetty server. Remark: the location of the web.xml file is inside the folder WEB-INF:

A typical tree under Jetty looks like this:
C:\Jetty\jetty-5.1.10\webapps\                                 - Base directroy of server install;
C:\Jetty\jetty-5.1.10\webapps\test                          - Directory for application test, Jython script code base;
C:\Jetty\jetty-5.1.10\webapps\test\WEB-INF              - Application servlet and web configurations;

URL to access the servlet: http://localhost:8080/test/JythonServlet1
 
Sample of the configuration file:  web.xml
 
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <display-name>test</display-name>
  <description></description>  
  <servlet>  
    <servlet-name>PyServlet</servlet-name>  
    <servlet-class>org.python.util.PyServlet</servlet-class>  
    <load-on-startup>1</load-on-startup>  
  </servlet>
  <servlet-mapping>
    <servlet-name>PyServlet</servlet-name>
    <url-pattern>*.py</url-pattern>
  </servlet-mapping>
</web-app>  

web.xml for Geronimo (IBM WebSphere-CE).
Remark: the location of the file is inside the folder WEB-INF:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                             http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
         version="2.5">

    <servlet>
      <servlet-name>PyServlet</servlet-name>
      <servlet-class>org.python.util.PyServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>PyServlet</servlet-name>
      <url-pattern>*.py</url-pattern>
    </servlet-mapping>                  
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>    
   </web-app>

geronimo-web.xml for Geronimo (IBM WebSphere-CE).
Remark: the location of the file is inside the folder WEB-INF:  

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0">
   <environment>
     <moduleId>
        <groupId>test.applications</groupId>
        <artifactId>test</artifactId>
        <version>1.1</version>
     </moduleId>
        <dependencies>
               <dependency>
            <groupId>test.applications</groupId>
            <artifactId>jython.jar</artifactId>
            <version>1.1</version>
            <type>jar</type>              
          </dependency>
        </dependencies>
   </environment>
   <context-root>/test</context-root>
</web-app>


Step 3 - Servlet code (O.K.)
from javax.servlet.http import HttpServlet
class JythonServlet1 (HttpServlet):
    def doGet(self,request,response):
        self.doPost (request,response)
    def doPost(self,request,response):
        toClient = response.getWriter()
        response.setContentType ("text/html")
        toClient.println("<html><head&><title>Servlet Test</title>" +
          "<body:<h1>Servlet Test</h1></body></html>")

For quick testing I recommend to use the Jetty web server in place of Tomcat (download here). For servlet deployment, check the functions and admin-tool of IBM WebSphere Community Edition (download here).

Hope this helps to run the servlet sample. Good luck.

Regards.
Claude

Claude Falbriard
Developer
AMS Hortolāndia / SP - Brazil
phone: +55 13 8126 7787
cell:       +55 13 8117 3316
e-mail:  claudef@br.ibm.com



rachmat@cs.its.ac.id
Sent by: jython-users-bounces@lists.sourceforge.net

02/05/2008 03:05 PM

To
jython-users@lists.sourceforge.net
cc
Subject
[Jython-users] learn in http://seanmcgrath.blogspot.com/JythonWebAppTutorialPart1.html





i'm try jython servlet,,

i have problem with it..

i finished learn manual in
http://seanmcgrath.blogspot.com/JythonWebAppTutorialPart1.html

but i have problem such as :


The full web.xml now looks like this:
<web-app>
<servlet>
<servlet-name>ServletTest</servlet-name>              
<servlet-class>ServletTest</servlet-class>
</servlet>
<servlet>
<servlet-name>PyServlet</servlet-name>
<servlet-class>org.python.util.PyServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletTest</servlet-name>
<url-pattern>/ServletTest</url-pattern>
</servlet-mapping>  <servlet-mapping>  <servlet-name>PyServlet</servlet-name>
<url-pattern>*.py</url-pattern>
</servlet-mapping>
</web-app>

JythonServlet1.py :

from javax.servlet.http import HttpServlet
class JythonServlet1 (HttpServlet):
def doGet(self,request,response):
self.doPost (request,response)
def doPost(self,request,response):
toClient = response.getWriter()
response.setContentType ("text/html")
toClient.println ("&lt;html&gt;&lt;head&gt;&lt;title&gt;Servlet
Test&lt;/title&gt;" + "&lt;body&gt;&lt;h1&gt;Servlet
Test&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;")

and i run localhost:8080/jythondemo/JythonServlet1.py,,,
but JythonServlet.py is not find...

any solution ?

rachmat




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users