Jump to Real's How-to Main page

List Web Application

Here a Servlet that will display Web applications installed. This is done by querying the Jaguar's Repository.
package com.rgagnon.servlet;           

import javax.servlet.*;
import javax.servlet.http.*;

import org.omg.CORBA.*;
import SessionManager.*;
import com.sybase.jaguar.system.Repository;
import com.sybase.jaguar.system.RepositoryHelper;
import com.sybase.jaguar.system.*; 

public class ListWebApp extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void destroy() { }

    protected void processRequest
       (HttpServletRequest request, HttpServletResponse response)
       throws ServletException, java.io.IOException {
        response.setContentType("text/html");
        java.io.PrintWriter out = response.getWriter();
        
        try {
            String hostname = request.getServerName(); 
            String servername = 
              com.sybase.jaguar.server.Jaguar.getServerName(); 
            
            out.println
              ("<html><head><title>Web apps</title></head><body>");
            out.println
              ("<b>hostname</b> " + hostname + "   [" + servername + "]");
            
            out.println("<P>Web applications:<p><ul>") ;
            String webappView[][] = repository.items("WebApplication", "");
            int j = webappView.length;
            for(int k = 0; k < j; k++) { 
               out.println("<li>" + webappView[k][1] );
            }
            
            out.println("</body></html>");
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            out.close();
        }
        
    } 

    protected void doGet
     (HttpServletRequest request, HttpServletResponse response)
     throws ServletException, java.io.IOException {
        processRequest(request, response);
    } 

    protected void doPost
     (HttpServletRequest request, HttpServletResponse response)
     throws ServletException, java.io.IOException {
        processRequest(request, response);
    }

    public String getServletInfo() {
        return "List Web Apps";
    }

}

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]