Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass implicitobject(out) in the methods?

 
Neelima Paramsetty
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
i have the following code
<%@ page import="java.io.*" %>
<HTML>
<HEAD>
<TITLE>MYOWNJSP</TITLE>
</HEAD>
<BODY>
<H1>THE REULT IS </H1>
<%!
int add(int a,int b,HttpServletResponse res) throws IOException
{
PrintWriter out=res.getWriter();
out.println("hello Neelima");
return a+b;
}
%>
<%= add(4,5,response) %>
</BODY>
</HTML>
how i have to pass the out object to the method?
Thanks in advance,
Neelima
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the response's PrintWriter interferes with buffering and can cause output to appear in the wrong order, as your example demonstrates.
Instead, use the JspWriter "out":
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic