[OpenMap Users] Blank Image on Servlet Example

From: Jim Schimmoeller <jschimmoeller_at_wowway.com>
Date: Tue, 24 Aug 2004 21:53:30 -0400

First, I am new to GIS / Mapping.

I downloaded openmap-4.6 and found the example ImageServlet. I have deployed
the servlet and it put some debugging statements in so I know I have a
properties file. However, when I run the servlet it completes successfully
(no errors at all) but image is blank; it is there because when I hover my
mouse over it the image toolbar shows up. I do have -Djava.awt.headless=true
set.

Below is my servlet code. Any help would be greatly appreciated.

Jim


---------------------servlet code
----------------------------------------------

import java.io.*;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.bbn.openmap.PropertyHandler;
import com.bbn.openmap.image.MapRequestHandler;

//---Servlet that will serve up images to MDSS applications
public class ImageServlet extends HttpServlet {

      //---Setting up the object that does the image creation
      private MapRequestHandler mapRequestHandler = null;
      private Properties properties = null;

      //---First method called when servlet is loaded
      public void init(ServletConfig config) throws ServletException {
            super.init(config);
            try {
                                File f = new
File("/tmp/openmap.properties");
                                System.out.println("File f = " + f);
                                System.out.println("exists=" + f.exists());
                                System.out.println("readable=" +
f.canRead());
                    System.out.println("writeable=" + f.canWrite());
                    f = null;
                properties = new
PropertyHandler("/tmp/openmap.properties").getProperties();
                mapRequestHandler = new MapRequestHandler(properties);
            } catch (Exception e) {
                  System.err.println(e.toString());
            }
      }

      //---Handle the HTTP GET method by building a simple web page.
 
//(REQUEST=MAP&SCALE=19000000&LAT=38&LON=-96&PROJTYPE=merc&HEIGHT=650&WIDTH=
1100&LAYERS=usStates,usCounties,usInterstates)


      public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
      {
            String queryString = request.getQueryString();
            response.setContentType("image/gif");
            if(queryString == null || queryString.indexOf("REQUEST=MAP") ==
-1)
            {
                                System.out.println("setting the default
string");
                 queryString =
"REQUEST=MAP&SCALE=27000000&LAT=38&LON=-96&PROJTYPE=merc&HEIGHT=600&WIDTH=80
0&LAYERS=usStates,usCounties";
            }
            byte arr[] = mapRequestHandler.handleRequest(queryString);
            response.getOutputStream().write(arr);
      }

      //---Method called via a POST request
      public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
      {
      }
      //---Last method to be called before servlet termination (or
expiration)
      public void destroy() {
            mapRequestHandler = null;
            properties = null;
            super.destroy();
      }
}

  

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Aug 24 2004 - 22:26:31 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:05 EDT