Forums Register Login

Printing out the environment variables on the browser

+Pie Number of slices to send: Send
Hi to all,
I need to print out the environment variables on the browser but I'm not sure how to do this. I want them in the format...
os.name=osname etc
I tried using Iterator and hashtable to do it but i failed. Please show me howto. Thanks. My current code is listed below but it prints then out the wrong way.
<%@ page import="java.util.Properties,java.util.HashMap"%>
<%
Properties p = new Properties();
p = System.getProperties();
HashMap m = new HashMap(p);
out.println(m.keySet() +"=" +m.values());
%>
+Pie Number of slices to send: Send
There's no need to create a hashmap from the Properties instance. The Properties method propertyNames() will return an Enumeration of the the property names. You can then iterate over those and use getProperty() to obtain the corresponsing values.
The javadoc is your friend!
hth,
bear
[ April 11, 2002: Message edited by: Bear Bibeault ]
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2793 times.
Similar Threads
Iterating through HashMap of HashMaps
How to declare HashMap in HashMap
Problem with serializing HashMap class variables.
hashmaps to xml and back
Need to know what kind of values and how to pass them to Map<String String>
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:48:16.