Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 10. Using Java Libraries > Servlets and PyServlet

10.2. Servlets and PyServlet

Although Java was initially designed to provide web applications on the client using applets, these days you are more likely to see Java deployed on the web server using servlets. The full servlet API is, of course, accessible from Jython. You can create servlets by defining servlet classes and compiling them via jythonc in much the same way as you would for applets.

However, you don’t have to go through that separate compilation step for servlets. Jython is distributed with a utility class org.jython.util.PyServlet, which allows you to use your Jython servlets in their uncompiled .py form. The PyServlet class is not, as you might expect, a parent class for your Jython servlets. Rather, it is the glue between your Jython code and the servlet engine. As far as the servlet engine is concerned, PyServlet is what gets called, and PyServlet manages the calling of the Jython code, through an embedded PythonInterpreter object.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial