Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to render data in Write Object on JSP  RSS feed

 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
I am trying to develop some generic code for the entire application. For that I have written the POJO . In that POGO I am writing the HTML code in Write object as follows.

out.Write ("<img border=\"0\" class=\"hlpBg hlpBdr\" src=\"");

where out is a Reference of Writer class.

However I am not getting how to render the code (the HTML code which I have writeen in Write object on JSP . )
ANy link or white paper will be greatly appreciated.
Thanks in advance
Regards
Samir
 
Pravin Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your POJO needs to either have a setter or thru constructor
initialize the Writer Object.
 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pravin ,
I did not understand one thing ...how can I instantiate the Writer object. Its a abstract class. And more over my issue is not with writing the data in Write object. I want to know how can I render the data which I have filled in the Write object.


Regards
Samir
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't instantiate the output writer. You can get an instance from the request object if this class is called from a servlet, or use the implict "out" object if this is in a JSP.

If this POJO class is used in a JSP, then you'll have to pass the out object to its method. That's not good design, though. It would be much better to give the POJO JavaBean characteristics, and then use JSTL and EL to output its data.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is meant to replace this type of architecture.

If you're going to build and format your output from POJOs, why bother with JSP at all? Just do everything from servlets.
 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Ulf,Bean and pravin ,
I understand the suggestions given by Ulf and Bean . And will adopt the same way that the Ulf has suggested.
Thanks a lot for your valuable help
Regards
Samir
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!