?? readme.htm
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
<META NAME="GENERATOR" Content="Visual Page 2.0 for Windows">
<TITLE>MapperServlet code example</TITLE>
</HEAD>
<BODY TEXT="black" BGCOLOR="white" LINK="red" ALINK="#FF6600" VLINK="#660033">
<H1 ALIGN="CENTER">MapperClientApplet/MapperServlet Code Example</H1>
<H2>Introduction</H2>
<P>MapperClientApplet and MapperServlet are a simple Java applet and servlet which use MapXtreme Java Edition to
generate map images (GIFs). Once the servlet is running on your server, users can use the applet to view map images.</P>
<P></P>
<H2>System Requirements</H2>
<P>
<TABLE BORDER="0" WIDTH="100%">
<TR>
<TD WIDTH="17%" VALIGN="TOP">Server-side Requirements:</TD>
<TD WIDTH="83%">Your MapXtreme Java Edition map servlet (<B>com.mapinfo.mapxtreme.MapXtremeServlet</B>) must be configured correctly
before you can run <B>MapperServlet</B>. <BR>
<BR>
MapperServlet will run on any server that is configured to run servlets. If you have not yet chosen a web server,
you can serve both servlets and HTML pages with the Tomcat web server, which is included with MapXtreme (as a separate
install option). </TD>
</TR>
<TR>
<TD WIDTH="17%" VALIGN="TOP">Client-side Requirements:</TD>
<TD WIDTH="83%">MapperClientApplet must be configured with the web server. You will need to either set an initialization parameter
(in the HTML file that loads the applet) or edit the MapperClientApplet source code to supply the URL needed to
connect to MapperServlet. <BR>
<BR>
The end user must have a Java-enabled web browser with at least a Java 1.1 VM. </TD>
</TR>
</TABLE>
</P>
<H2>List of Files</H2>
<P>The MapperServlet application consists of the following files:</P>
<UL>
<LI>MapperServlet.java: the source code for a servlet.
<LI>MapperClientApplet.java: the source code for an applet.
<LI>RunApplet.html: a web page used to load the applet.
<LI>readme.htm: this document.
</UL>
<P>
<H2>Configuring the Servlet</H2>
<P>1. Before connecting to the MapperServlet, you must specify configuration information, such as the filename
of a map definition or geoset file to load and the path to the maps directory used by that geoset. You can either specify this information
through initialization parameters (e.g. in the web.xml file used by Tomcat), or by editing MapperServlet.java and
assigning the values at the top of the file. If you do set up initialization parameters, those initialization parameter
values will override the values hard-coded into MapperServlet.java. </P>
<P>The following are the member variables and the corresponding init parameter that need to be set:</P>
<BLOCKQUOTE>
<H6>MapperServlet Member variables (with example values)</H6>
<P>private static String m_mapPath = "C:\\mapxtreme\\examples\\server\\data\\";<BR>
private static String m_fileToLoad = "C:\\mapxtreme\\examples\\server\\data\\world.gst";<BR>
private static String m_mxtURL = "http://hostname:8080/mapxtreme45/servlet/mapxtreme";<BR>
private boolean m_debug = false;<BR>
private int m_mapWidth = 500;<BR>
private int m_mapHeight = 500;</P>
<H6>MapperServlet initialization parameter keys</H6>
<P>mappath<BR>
filetoload<BR>
mapxtremeurl<BR>
debug<BR>
mapwidth<BR>
mapheight</P>
</BLOCKQUOTE>
<P>If you ran the Tomcat installer provided with MapXtreme, then the main initialization parameters have already
been set up for you, in the file tomcat/mxj450/webapps/samples45/WEB-INF/web.xml. For example, the following excerpt
from the web.xml file shows how the <B>filetoload</B> parameter is assigned: </P>
<PRE> <init-param>
<param-name>
filetoload
</param-name>
<param-value>
C:\mxt\maps\world.gst
</param-value>
</init-param></PRE>
<P></P>
<P>2. Compile <B>MapperServlet.java</B>.
(Note: In a standard installation of MapXtreme Java,
this has already been done for you; see mxjserversamples.jar.)
Note that you will need to set up your compiler or development environment
so that its classpath includes both the path to the main MapXtreme jar file (mxtj.jar) and the path to the JSDK's
servlet.jar file.</P>
<P>3. Copy the resulting class file to the appropriate directory on your server (the directory where servlet class
files are stored). For example, you might copy MapperServlet.class to:<BR>
<B>tomcat/mxj450/webapps/samples45/WEB-INF/classes</B>.
(Note: In a standard installation of MapXtreme Java,
this has already been done for you; see mxjserversamples.jar.)
</P>
<P>4. Configure your system so that your servlet engine can find MapXtreme jar files, such as mxj.jar.
The exact procedure for doing this depends on which servlet engine you use. If you ran the Tomcat installer provided
with MapXtreme, then this step has already been performed for you. </P>
<P>5. Start your servlet container. The exact command used to start the server depends on which servlet container
you are using. If you ran the Tomcat installer provided with MapXtreme, you can start Tomcat by running startup.bat
(on Windows) or startup.sh (on Unix). </P>
<P><B>Note:</B> Whenever you modify and recompile a servlet, you may need to restart your servlet engine for your
changes to take effect.</P>
<H2>Configuring the Applet</H2>
<P>1. The MapperClientApplet has an initialization parameter that specifies the URL needed to connect to the MapperServlet.
You can specify this URL in one of two ways: Either specify the URL in the PARAM tag in the file RunApplet.html,
or edit MapperClientApplet.java and assign the URL to the variable m_servletName: </P>
<BLOCKQUOTE>
<P>private static String m_servletName ="http://hostname:8080/samples45/servlet/mapper";<BR>
</P>
</BLOCKQUOTE>
<P><B>Note:</B> If you specify the URL by editing MapperClientApplet.java, you should
remove the MapperServlet URL from RunApplet.html. (When the MapperServlet URL is present
in the HTML file, that URL overrides any URL specified in the applet source code.)
</P>
<P>2. Compile <B>MapperClientApplet</B>. (Unless you have customized MapperClientApplet.java,
this step is optional, since the MapXtreme installation provides .class files for MapperClientApplet.) </P>
<P>3. Copy the resulting class files and the sample .html file to the appropriate directory on your server (the
directory where applet class files are stored). For example, if you are using
the Apache/Tomcat installation provided with MapXtreme, you might create a 'test' directory:
C:/apache-1.3.20/htdocs/test
and copy your files to the test directory. Then view the applet by typing in the URL:
</P>
<P>http://hostname:8080/test/RunApplet.html </P>
<P>Note: Because of applet security issues, you need to be careful about
how you specify the host name when you type the web page's URL into your browser.
If your applet has been configured to use "localhost" as its host name,
you will need to specify "localhost" when you type the URL into your browser.
Or, if you specified an explicit host name such as "mycomputer.mycompany.com"
in all of your URLs (in your web.xml file, HTML file, and Java source code),
then you should also use "mycomputer.mycompany.com" as the host name
when you type the applet page's URL into your browser.
</BODY>
</HTML>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -