Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing out the environment variables on the browser  RSS feed

 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
%>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!