db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maurice Wijtten" <maur...@dieka.com>
Subject [documentation] contributing init servlet
Date Wed, 29 Jan 2003 15:07:39 GMT
Hello Torque developers,
 
I was introduced with Torque by the usage of it in Jetspeed. I was very
fascinated about the developing speed. One of the disadvantages is the
documentation. An important rule at having critics is helping to get it
better! I don't now if my contribution is welcome, but if might help
beginning programmers a bit on the way. I found that writing a little
initservlet is a very simple way of combining Torque and Struts 
together. The code fragments in this mail are my TorqueInitServlet and
the code fragment of web.xml which has to be inserted.
If any help is appreciated i have no trouble writing a little tutorial
describing the install of torque together with Struts.
 
I hope my help can contribute the project,
 
Maurice Wijtten, the Netherlands
Maurice@dieka.com
 
 
 
 
<?xml version="1.0" encoding="ISO-8859-1"?>
 
<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
 
<web-app>
 
  
  
  <servlet>
    <servlet-name>TorqueInitServlet</servlet-name>
 
<servlet-class>nl.mycompany.startup.TorqueInitServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
  </servlet>
  
</web-app>
 
 
 
 
And the TorqueInitServlet
 
 
/*
 * Servlet.java
 *
 * Created on January 21, 2003, 10:41 AM
 */
 
package nl.mycompany.startup;
 
import java.io.*;
import java.net.*;
 
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.torque.*;
 
/**
 * Initialisation Servlet which is called automaticaly at
 * the start of the servlet container.
 * Don't forget the  <load-on-startup>  in web.xml
 * @author  Maurice Wijtten
 * @version 1.0
 */
public class TorqueInitServlet extends HttpServlet {
    
    /** Initializes the servlet.
     */
    
    
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        try{
        System.out.println("Initializing Torque");
        String TorqueProperties =
config.getServletContext().getRealPath("/WEB-INF/conf/Torque.properties"
);
        Torque.init(TorqueProperties);
        System.out.println("Torque has been initialized.");
        }
        catch(org.apache.torque.TorqueException te){
            te.printStackTrace();
        }
    }
    
    /** Destroys the servlet.
     */
    public void destroy() {
        
    }
  
}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message