• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can anybody give me some idea?

 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is adapted from JSP specification 2.7:
**** Initially, out is a new JspWriter object. This object may be different from the
stream object returned from response.getWriter(), and may be considered to be
interposed on the latter in order to implement buffering (see Section JSP.2.10.1, 揟he page Directive?. This is the initial out object. JSP
page authors are prohibited from writing directly to either the PrintWriter or OutputStream associated with the ServletResponse.
****
I am not very sure what it means. Thanks in advance!
Xiaoma Wang
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO, this means that the implicit object out is a buffered version of the generated servlet's PrintStream. As a JSP developer, you are expected to use the implicit object rather than writing to the PrintStream of the servlet.
This recommendation must be followed so that the App server can take advantage of buffering the stream. Remember the app server is required to implement a minimum buffer size of 8 kb, right?
regds.
- madhav
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the by -- consider custom (Body) tags. They work by virtue of pushing the original "out" onto a stack, and replacing it with a new, memory-backed one that captures the tag body for further processing. This entire technique would break if code inside the tag were to use the ServletResponse's output stream.
- Peter
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Come to think of it, I'm actually a bit mystified by the specification's reference (JSP.2.7) to buffering. There's no need to create an output stream wrapper for that -- a simple call to ServletResponse.setBufferSize() would do just nicely.
- Peter
 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, madhav and Peter,
I am getting more clear now .
Thank you!
 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
If I set the jsp directive "buffer" to "null", then does it mean that using response.getWriter() and using implicit object "out" has the same effect? Since there is no buffer..
Regards
-Xiaoma Wang
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no need to create an output stream wrapper for that -- a simple call to ServletResponse.setBufferSize() would do just nicely.
Peter:
IMO, it is a little more than "a simple call" maybe. Some things this logic must take into consideration are:
  • buffer attribute of the page directive.
  • include directive (translation behavior). The original page has a buffer size that is different from the included page.
  • include action (runtime behavior).


  • Comments, please ?
    Thanks.
    - madhav
     
    Madhav Lakkapragada
    Ranch Hand
    Posts: 5040
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If I set the jsp directive "buffer" to "null",
    that would be "none".
    - madhav
     
    Peter den Haan
    author
    Ranch Hand
    Posts: 3252
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Madhav Lakkapragada:
  • buffer attribute of the page directive.
  • Knee-jerk reaction would be that this could be translated into a call to response.setBufferSize(). They have the same semantics (the buffer will be the indicated size or more).
  • include directive (translation behavior). The original page has a buffer size that is different from the included page.
  • Nope -- an <%@include%>d file is not a page and has no independent buffer settings. It works like a C preprocessor #include.
  • include action (runtime behavior).

  • The <jsp:include> semantics in the JSP specification exactly match the RequestDispatcher.include() semantics in the Servlet specification. Neither is terribly clear on how buffering works in this case, but in the absence of a statement to the contrary you would assume that the included page & servlet can set its own buffer size. It is not clear why JSPs would need to wrap the output stream to implement buffering.
    I could well be missing something obvious tho.
    - Peter
    [ May 11, 2002: Message edited by: Peter den Haan ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic