<%
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);
MgMap map = new MgMap(siteConnection);
map.open(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();
out.println("