List Web Application(this howto is deprecated)Tag(s): DEPRECATED


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";
    }

}

blog comments powered by Disqus