Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing key/value pairs in separate lines  RSS feed

 
chandu boyapati
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai to all,

...I am new to jsp development.I am trying to retrieve system properties using
the method "System.getProperties()".I did this using the fallowing code.

==========
%@page import="java.util.Date"%>
<%@page import="java.lang.reflect.Array"%>
<%@page import="java.util.Properties"%><HTML>
<body bgcolor="#000000" text="#FFFFFF">
<BODY>
<%
Properties prop=System.getProperties();
out.println(prop);
%>

</BODY>
</HTML>

==========
..Above code prints all key/value pairs together. I want to print them
in a separate lines
.
..Can any one please help in reading key/value pairs and printing them
separate lines.


..I am using apache-tomcat
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put them in the appropriate HTML markup. And stop putting Java code in your JSPs.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A linebreak in HTML is to be represented by the <br> element.

I highly recommend you to learn HTML before playing with JSP. This is really trivial. There's a good HTML tutorial at w3schools.com.
 
chandu boyapati
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really appreciate your immediate replies.

...I read a tutorial (http://www.jsptut.com/Scriptlets.jsp) which says JSP also allows you to write blocks of Java code inside the JSP.
...I do know how to print data in separate lines using HTML.
...What I am trying to do here is writing small scriptlet using java to read properties and then printing them in separate lines.In this scriptlet I have to use <BR> to get separate line feature but I have doubt in writing logic for loop to read and print properties.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chandu boyapati wrote:I really appreciate your immediate replies.

...I read a tutorial (http://www.jsptut.com/Scriptlets.jsp) which says JSP also allows you to write blocks of Java code inside the JSP.

Probably an old one. if not, then not a very good one. Modern best practices discourage (strongly) the inclusion of Java scriptlets in JSPs.

Just because you can hit yourself in the forehead with a ball-peen hammer doesn't mean that you should.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chandu boyapati wrote:but I have doubt in writing logic for loop to read and print properties.

The list of properties should be placed in request scope by the page controller. Then the JSTL and EL can be used to iterate through the list and produce the appropriate HTML output.

I suggest you find a modern tutorial that discusses JSTL and EL rather than old-fashioned scriptlets.
 
chandu boyapati
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for guiding me to develop good jsps.Is there any specific book you can suggest for learning JSPs.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JavaRanch Bunkhouse is a great place to start to find books on such subjects.

There you will find not only lists of books on various Java and web-related subjects, but expert reviews of these books.

Take a look!

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!