• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

formating lines in jsp  RSS feed

 
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I print line by line in a JSP page? When I print using out.println(), it prints in the same line with the previous line.

Thanks in Advanced!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because you should be outputting HTML. What does HTML do with a newline? Ignores it.

(And why are you generating HTML with an out.println()???)
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you use out.println() in a JSP? Use of scriptlets in JSP is discouraged. As far your question goes, having a look at the container generated servlet code for your JSP will clear your doubt.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below, that is my code,

I need print every book in a line, but here, it prints in the same line. What is the solution?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Newton wrote:That's because you should be outputting HTML. What does HTML do with a newline? Ignores it.


No, really: output HTML. How do you get a line break in HTML?
 
Ranch Hand
Posts: 129
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you use JSTL instead of scriptlets...

using scriptlets in your jsp pages are outdated now ....

this link may help you to convert your code using JSTL

JSTL BASICS


 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David Newton, I got that break, and vijin das, thanks a lot for that suggestion. I'm a newbie, so I'll try to catch it up! Thanks guys!
 
Ranch Hand
Posts: 282
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you MUST use scriptlets (which you shouldn't), you can import classes into your JSP by using the page directive. That way, you don't have to write the fully-qualified names of all the classes. For example:
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael Angstadt...
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't see the rest of the thread. Comment was not relevant.
 
Sheriff
Posts: 67259
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a newbie, form good habits now. No java code (scriptlets) in JSPs.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:As a newbie, form good habits now. No java code (scriptlets) in JSPs.


Thanks Bear Bibeault for this suggestion, It's great! Then should I go to JSTL? Thanks in Advanced!
 
Bear Bibeault
Sheriff
Posts: 67259
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, your JSPs should use the JSTL and the EL in place of old-fashioned scriptlets.

If you need more power, that's where more advanced capabilities such as custom tags, tag files, and EL functions come in.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.....
 
Those are the largest trousers in the world! Especially when next to this ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!