Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet println Question..max possible string length?

 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
When writing a servlet I like to do the HTML in Dreamweaver and then paste it in.
But breaking it all up into little println(); statements seems a little cumbersome.
Does anybody know the max String length permitted??
Could I put a large part of a page in?
Thanks,
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max String length will be determined by the amount of memory you have available. You can put the whole page in if you like. One giant String will work, but you have to stitch the lines together with + since Java won't take a 0x0D or 0x0A in the middle of a String declaration.
Alternately, consider reading the HTML from a file during servlet initialization - this makes it easy to change the HTML without recompiling the servlet.
Bill
------------------
author of:
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Thanks for the idea Bill. Would there be any performance factors involved in accessing both a servlet file and a text file?
I had seen the odd example around that had top-of-page menus and bottom-of-page stuff included using the <jsp:include > tag in jsp.
With a servlet I suppose I could use a FileInputStream or such like.
Does anyone know of a link to performance comparisons about the different file access methods in Java?
Thanks,
Terry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!