Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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: 25594
69
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: 25594
69
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.
 
Lookout! Runaway whale! Hide behind this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic