Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formatting data for view

 
Thejaswi Narayana
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application I am working on gets the data from the business tier as a list of value objects. Before forwarding the data to the view I need to format the data so that I can display it in the JSP without having to use scriplets. View helper is one of the strategy. But we are not using any custom data and want to do all the formatting of data in the servlet before passing on to JSP. Can anyone let me know what are the strategies for doing the formatting.

Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Genreally I do not do formatting in the servlet as that is part of presentation rather than control. To avoid scriplets on the page (a good idea, btw), I use either JSTL formatting tags as applicable, or my own custom tags.
 
Ct Arrington
Author
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might take a look at Apache's Element Construction Set (ECS)

It makes the horribly tedious and error prone task of generating HTML in code slightly more tolerable.

I would definitely recommend using some sort of helper class to do the actual formatting.

Hope it helps
CT
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why on earth would he want to move the HTML generation out of the JSP?
 
Thejaswi Narayana
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Decided to go with the Helper class. Thanks for the reply
 
Naren Desai
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A seperate helper class is a good idea.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nah",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic