Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

HTML tags within JSP scriptlet without using printwriter

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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: 25467
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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: 17
  • Mark post as helpful
  • send pies
  • 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: 25467
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All right! And yeah, that looks a lot better than the original.
 
I'm doing laundry! Look how clean this tiny ad is:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic