• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending HTML page to client side

 
Anu Pasricha
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)I am sending the whole HTML page using out.println, in doGet method.
I want to know, is this the correct method to do it or should i create a stringbuffer and return that from servlet.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is certainly reasonable to output the HTML page by means of lots of out.println() statements, but there are other possibilities.
You could build up a StringBuffer and then do a single out.println( yourStringBuffer.toString() ); for example.
Are you worried about performance or what?
Bill
 
Murtaza Hussaini
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you are scared of too many out.println() statements that you have to write in servlets. Why don't you learn a bit about Java Server Pages. This theme behind this technology is to avoid those out.println() statements.
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I second that recomendation. Even simple pages can become very difficult to maintain when they are built up in Java code. The combination of servlets and JSP pages (following the Model 2 pattern) is a powerful combination for creating robust web applications.
hth,
bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!