<%
String sessionId = request.getParameter("SESSION");
String mapName = request.getParameter("MAPNAME");
try
{
// Initialize the Web Extensions and connect to the Server using
// the Web Extensions session identifier stored in PHP
// session state.
MapGuideJavaApi.MgInitializeWebTier(webconfigFilePath);
// Get the user information using the session id,
// and set up a connection to the site server.
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
// Get an instance of the required service(s).
MgResourceService resourceService = (MgResourceService) siteConnection.CreateService(MgServiceType.ResourceService);
MgMap map = new MgMap();
map.Open(resourceService, mapName);
MgLayerCollection layers = map.GetLayers(); // Get layer collection
MgLayer roadLayer = (MgLayer) layers.GetItem("Roads");
String roadLabel = roadLayer.GetLegendLabel();
String newLabel;
if (roadLabel.equals("Roads"))
newLabel = "Streets";
else
newLabel = "Roads";
roadLayer.SetLegendLabel(newLabel);
// You must save the updated map or the
// changes will not be applied
// Also be sure to refresh the map on page load.
map.Save(resourceService);
out.println("