1 2 24 25 26 27 28 29 package com.lutris.appserver.server.httpPresentation; 30 31 import com.lutris.applet.LBSConnection; 32 33 34 45 public class AppletUtils { 46 47 50 private AppletUtils() { 51 } 52 53 54 86 public static String createAppletTag( 87 HttpPresentationComms comms, 88 String targetURL, 89 String options, 90 String [] parameterNames, 91 String [] parameterValues, 92 String alternateHtml) { 93 96 if (targetURL == null) 97 targetURL = ""; if (options == null) 99 options = ""; if (alternateHtml == null) 101 alternateHtml = ""; 102 105 StringBuffer result = new StringBuffer (); 106 result.append("\n<APPLET "); 107 result.append(options); 108 result.append(">\n"); 109 112 if ((parameterNames != null) && (parameterValues != null)) 113 for (int i=0; i<parameterNames.length; i++) { 114 result.append("<PARAM NAME="); 115 result.append(parameterNames[i]); 116 result.append(" VALUE="); 117 result.append(parameterValues[i]); 118 result.append(">\n"); 119 } 120 123 String cookieName = comms.application.getName(); 124 String cookieValue = comms.session.getSessionKey(); 125 128 String server = comms.request.getServerName(); 129 int port = comms.request.getServerPort(); 130 String pp = "/"; 131 try { 132 pp = comms.request.getApplicationPath(); 133 } catch (HttpPresentationException e) { 134 } 135 if (!pp.startsWith("/")) 136 pp = "/" + pp; 137 if (!pp.endsWith("/")) 138 pp = pp + "/"; 139 if (targetURL.startsWith("/")) 140 targetURL = targetURL.substring(1); 141 String fullURL = "http://" + server; 142 if (port != 80) 143 fullURL += ":" + port; 144 fullURL += pp + targetURL; 145 152 result.append("<PARAM NAME="); 153 result.append(LBSConnection.nameParamName); 154 result.append(" VALUE="); 155 result.append(cookieName); 156 result.append(">\n"); 157 result.append("<PARAM NAME="); 158 result.append(LBSConnection.valueParamName); 159 result.append(" VALUE="); 160 result.append(cookieValue); 161 result.append(">\n"); 162 result.append("<PARAM NAME="); 163 result.append(LBSConnection.targetParamName); 164 result.append(" VALUE="); 165 result.append(fullURL); 166 result.append(">\n"); 167 170 result.append(alternateHtml); 171 result.append("\n</APPLET>\n"); 172 175 return result.toString(); 176 } 177 178 179 } 180 | Popular Tags |