It's not a secret anymore!*
The moose likes Servlets and the fly likes Formatting data for view Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Formatting data for view" Watch "Formatting data for view" New topic
Author

Formatting data for view

Thejaswi Narayana
Greenhorn

Joined: Apr 25, 2004
Posts: 27
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


Thejaswi Narayana<br />SCJP 1.4<br />SCBCD 1.3<br />SCDJWS
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ct Arrington
Author
Greenhorn

Joined: Jan 17, 2001
Posts: 27
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


Blog | Getting Started in Software Development
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Why on earth would he want to move the HTML generation out of the JSP?
Thejaswi Narayana
Greenhorn

Joined: Apr 25, 2004
Posts: 27
Decided to go with the Helper class. Thanks for the reply
Naren Desai
Greenhorn

Joined: May 12, 2005
Posts: 3
A seperate helper class is a good idea.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

"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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Formatting data for view
 
Similar Threads
When using MVC, to what degree should a model be tailored to a view?
looks like space but, very strange problem!
How can i structure that?
Notify JSP that ServletContext been changed?
Getters as well