I recently saw that there has been lots of discussion on the custom rest service legend sample posted on the code gallery in terms of getting the sample up and running successfully. If you have no clue on what I am talking about, here is the link.
This post should help you get the sample running in no time (almost):
I am using Eclipse (screen-shots show version 3.4/Ganymede, 3.3/Europa should work as well) as my IDE and ArcGIS Server 9.3.1 Java ADF libraries.
1. Download the sample on to the disk:

The sample comes with “json.jar” library, as shown in the screen-shot here:
2. Create a new project in eclipse
3. Import the source files and web-inf folder from the sample to the project
As you see, IDE complains that there are missing imports. We are going to fix them in step 4
4. Copy (drag and drop) the following libraries into the project from the Web ADF library collection
Note: You do not need ArcGIS Server to run this sample, just the Java Web ADF libraries is good. You can copy the required libraries from other machine if needed

After completing steps 3 and 4 you project should look like:
5. Run the web app (Assumption is that you have eclipse configured with web server like tomcat or jetty. I am using tomcat 6)
6. Optionally, you can export this into a war file for deployment
















May 19, 2009 at 12:07 pm
[...] Installing and running the Custom Rest Service – Mapservice legends sample [...]
May 27, 2009 at 5:05 am
Is there any .NET version? We are using ArcGIS Server for .NET. Thanks.
June 19, 2009 at 2:55 am
…and the example javascript showing how to consume the service is…where? :-/
July 2, 2009 at 8:55 am
@Moogletrop – Here is the sample available on resource center which shows how to consume the legend service from ArcGIS JavaScript API app – Link – Once you download this set of samples, and run the index.html page you will find link to the sample you are looking for. (you can also find it directly under functionality/restLegends.html and functionality/js/RestLegends.js)
July 29, 2009 at 2:56 pm
sathyaprasad
Is there any way you can compile a war file for me? I have followed your instructions and still getting a fair number of build errors. Thanks.
Cheers,
Blair
August 5, 2009 at 6:21 am
Thanks, nicely done.
A couple of changes I had to make to get the service to run:
1) There was no default (index.html) page included in the download, so I copied the online default page here (http://orthogonal.esri.com/restlegends/) and created my own.
2) In the index.html you have to add an action attr to the form tag that points to the servlet (action=”legends”).
3) In the jsps/legends-html.jsp page you also have to add an action attr to the form tag that points to the servlet (action=”../../legend/legends”).
October 12, 2009 at 1:31 am
i did so but receive those errors
1- Unable to generate legends: Invalid response from Server, HTTP status code {203} received from server.
And it happens when using default map service published on ESRI server
2- Unable to generate legends: Invalid response from Server, Response content type is text/html.
And it happens when using may own map service published on my server.
any comments??