View source | Discuss this page | Page history | Printable version   

ERP 2.50:Developers Guide/Concepts/Servlet Structure

ERP 2.50:Developers Guide




This document explains the current servlet hierarchy and structure in Openbravo ERP.

Class Hierarchy

Servlet Structure.png


Base class that extends from Sun's HttpServlet and implements ConnectionProvider interface. It contains all the methods to interact with the database connection pool. This class is part of Openbravo's core. Your servlet can extend from this class if you don't want authentication and authorization.


This class extends from HttpBaseServlet. The security of the application is implemented at this level. This class also contains common artifacts for things such as: render a JasperReport, Autosave implementation, Navigation history, etc.


This is an example servlet class. All your servlets should extend from HttpSecureAppServlet if you want authentication and authorization mechanisms.

Example Servlet

MyCustomServlet Example

package com.somepackage.mymodule;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.openbravo.base.secureApp.HttpSecureAppServlet;
import org.openbravo.base.secureApp.VariablesSecureApp;
public class MyCustomServlet extends HttpSecureAppServlet {
  private static final long serialVersionUID = 1L;
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
      ServletException {
    VariablesSecureApp vars = new VariablesSecureApp(request);
    if (vars.commandIn("DEFAULT")) {
      printPageDataSheet(response, vars);
    } else
  void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars)
      throws IOException, ServletException {
    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.println("This is MyCustomServlet");


Your servlet must override the doPost method with all the logic that you want to implement in the class. Generally you start with a new VariablesSecureApp object based on the request made. This object will contain all the data from the request, plus a lot of helper methods like commandIn(), etc. Your servlet should implement a "DEFAULT" action, that will be executed when no other command is passed to the servlet.

ERP 2.50:Developers Guide/Concepts/Middle Tier Fundamentals | ERP 2.50:Developers Guide/Concepts/XMLEngine 

Retrieved from ""

This page has been accessed 16,607 times. This page was last modified on 14 June 2011, at 11:03. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.