• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTML tags within JSP scriptlet without using printwriter

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using a backend service to

1) Fetch a list of users' email-addresses  and
2) Print them out in a table.

For now, I've used out.println to print out just the values without the table markup.

I don't want to use out.println to print table markup (feels a little dirty). Is there a better way to print table rows iteratively within a scriptlet ? Am I doing this the wrong way ? Please advise.



Thanks,
IC
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Izanami Caster wrote:I don't want to use out.println to print table markup (feels a little dirty). Is there a better way to print table rows iteratively within a scriptlet ? Am I doing this the wrong way ? Please advise.



Scriptlets? Yes, you are doing it the wrong way. Scriptlets have been obsolete for well over a decade now. Instead you should be using JSTL tags to generate output -- everything you have there in Java can be written in JSTL, and you can put HTML tags in there and have them go into the response. Give that a try instead.

And yeah, putting out.println in a scriptlet is icky. Back near the turn of the century we had to do that but then they invented JSTL, which is way better to work with.
 
Izanami Caster
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi @Paul!

The following worked.



I had to add the following:

1) Add <%@ taglib prefix="c" uri = "http://java.sun.com/jsp/jstl/core" %> to the JSP page. Doing this alone didn't help. So I also did 2.
2) Add the following maven dependency (POM) to support JSTL:



Thanks a lot for the help!

Thanks,
IC
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All right! And yeah, that looks a lot better than the original.
 
Grow your own food... or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic