Hans,
*** SOLVED!!! ***
Thanks for your advice... I realise it is inefficient to run Java as a CGI
...
it is taking about 8MB of mem a pop (cos of the JVM as you pointed out) ...
Anyway, we have redone it as a J++ COM component (.dll) and are calling it
from ASP which is working far better. (We had to install the MS Java SDK on
the server to get that to work though? - I think it was the WFC that was
needed)
But I did get it working as a CGI (.exe) so I thought I would post the class
I found for getting the environment variables!
I found it here ... all credits to "liquid_isotope" for posting it! :)
http://forum2.java.sun.com/forum?14@@.ee7780f
I have extended it with a parseQueryString method to give me what I needed.
Thanks,
Jonathan
=======================================================
Snip here!
=======================================================
Use it like this ...
// get environment variables
clsEnvironmentVariables ev = new
clsEnvironmentVariables();
String l_strBDGT_DPT_ID =
ev.querystring("BDGT_DPT_ID");
String l_strBDGT_ACT_CELL_REV_NO = ev.querystring("REV_NO");
=======================================================
import java.util.*;
import java.io.*;
class clsEnvironmentVariables extends Hashtable {
private Hashtable m_htQueryString;
public clsEnvironmentVariables() {
//You probably have to do something different in Unix or Mac
//but I don't know those yet, so this will only work in Windows
//--- liquid_isotope *->!
String[] cmd = {"cmd", "/c", "SET"};
try {
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader inp = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
String LINE = inp.readLine();
while (LINE != null) {
int eqPos = LINE.indexOf("=");
if (eqPos >= 0) {
String name = LINE.substring(0, eqPos);
String value = LINE.substring(eqPos + 1);
put(name.toUpperCase(), value);
// Call the private method to parse
the querystring
if (name.equals("QUERY_STRING")) {
this.parseQueryString(value); }
}
LINE = inp.readLine();
}
inp.close();
} catch (IOException e) {
System.out.println("Weird I/O error");
}
}
public synchronized Object get(Object name) {
// this case-desensitizes the name, overriding Hashtable.get()
String theName = name.toString().toUpperCase();
return super.get(theName);
}
public synchronized Object put(Object name, Object value) {
String theName = name.toString().toUpperCase();
String theValue = value.toString();
Object result = super.get(theName);
// this is windows specific
String[] cmd = {"cmd", "/c", "SET " + theName + "=" + theValue};
try {
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader inp = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
String LINE = inp.readLine();
while (LINE != null) {}
super.put(name.toString().toUpperCase(), value.toString());
return result;
} catch (IOException e) {
System.out.println("Weird I/O error");
return null;
}
}
public synchronized String querystring(Object pstrKey) {
// Returns items from the m_htQueryString HashTable
String l_strKey = pstrKey.toString().toUpperCase();
return (m_htQueryString.get(l_strKey)).toString();
}
private void parseQueryString(String pstrQueryString) {
// Parse the QUERY_STRING string into the m_htQueryString HashTable
m_htQueryString = new Hashtable();
StringTokenizer l_stPairs = new StringTokenizer(
pstrQueryString, "&", false );
while (l_stPairs.hasMoreTokens()) { // chop up on &
String l_strPair = l_stPairs.nextToken();
StringTokenizer l_stKeyValue = new StringTokenizer(
l_strPair, "=", false );// chop up on =
// Get the key
String l_strKey = l_stKeyValue.nextToken();
// Get the value
String l_strValue = "";
int l_intCount = 0;
while (l_stKeyValue.hasMoreTokens()) {
if (l_intCount > 1) { l_strValue += "="; }
l_strValue += l_stKeyValue.nextToken();
l_intCount++;
}
// Add the key/value pair to m_htQueryString
m_htQueryString.put(l_strKey.toUpperCase(),l_strValue);
}
}
}
=======================================================
Snip here!
=======================================================
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets