This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JSP and the fly likes how to pass implicitobject(out) in the methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to pass implicitobject(out) in the methods?" Watch "how to pass implicitobject(out) in the methods?" New topic
Author

how to pass implicitobject(out) in the methods?

Neelima Paramsetty
Greenhorn

Joined: Jun 17, 2003
Posts: 16
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

Joined: Jun 06, 2002
Posts: 1056
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":


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
 
rocket mass heater kickstarter
 
subject: how to pass implicitobject(out) in the methods?