Hi!
I hope I'm not overstepping any lines with this request. But I've been staring at this JSP function for a few hours and I'm grasping for some help. I need to rewrite this in PHP, which would not be a problem, if I knew what the JSP was actually doing/returning.
Any help would be GREATLY appreciated. Thanks!!
JSP CODE ------
function getMapData(mapURL){
echo mapURL;
url;
qString="";
//From what I've read this is grabbing everthing after the ? ??
StringTokenizer token = new StringTokenizer($mapURL,"?",false);
$url = token.nextToken();
while(token.hasMoreTokens()){
$qString += token.nextToken();
}
URL dataURL = new URL(url);
URLConnection connection = dataURL.openConnection();
// Make sure browser doesn't cache this URL.
//connection.setUseCaches(false);
// Tell browser to allow me to send data to server.
connection.setDoOutput(true);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(512);
PrintWriter out = new PrintWriter(byteStream, true);
String postData = qString;
// Write POST data into local buffer
out.print(postData);
out.flush(); // Flush since above used print, not println
// POST requests are required to have Content-Length
String lengthString =
String.valueOf(byteStream.size());
connection.setRequestProperty("Content-Length", lengthString);
// Netscape sets the Content-Type to multipart/form-data
// by default. So, if you want to send regular form data,
// you need to set it to
// application/x-www-form-urlencoded, which is the
// default for Internet Explorer. If you send
// serialized POST data with an ObjectOutputStream,
// the Content-Type is irrelevant, so you could
// omit this step.
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// Write POST data to real output stream
byteStream.writeTo(connection.getOutputStream());
java.io.BufferedInputStream in = new java.io.BufferedInputStream(connection.getInputStream());
java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
byte[] buffer = new byte[4096];
for (int read=0;(read=in.read(buffer))!=-1;bout.write(buffer,0,read));
return bout.toByteArray();
}
public String[] splitPiped(String str){
StringTokenizer token = new StringTokenizer(str.trim(),"|",false);
String[] rstr = new String[token.countTokens()];
int i=0;
while(token.hasMoreTokens()){
rstr[i++] = token.nextToken();
}
return rstr;
}
If anything I would just like it broken down saying what is does and is returning. Let me know if I can provide any more information.
Thanks!
Lisa