You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Dahnke, Eric" <ED...@nextsource.com> on 2002/03/21 03:06:02 UTC

BufferedReader oject between servlet and jsp

wondering if someone might help me out. I'm trying to pass a BufferedReader
object between a servlet and jsp page using the session. on the jsp page I
want to read out line by line the BufferedReader object. The idea works
within the servlet code as shown, but within the jsp page no matter what I
do

out.println(br);

shows something like this:

java.io.BufferedReader@3c550f 

and the while loop (in the jsp) never executes. Any ideas? (how can i
troubleshoot?)



I have a servlet with the following code:
===========================
BufferedReader br = new BufferedReader( new
InputStreamReader(proc.getInputStream()));

HttpSession session = request.getSession(true);
session.setAttribute("BufferedReader", br);			
			
String str;
while ((str = br.readLine()) != null) {
	System.out.println(str);
} //works

and a jsp page which is called from the servlet like this
============================
RequestDispatcher rd = request.getRequestDispatcher("en/bdy.jsp");
rd.include(request, response);

bdy.jsp
=====
<%@ page import="java.io.*" %>

<%
BufferedReader br = (BufferedReader) session.getAttribute("BufferedReader");
String str;
out.println(br);
while ((str = br.readLine()) != null) {
	out.println(str);
	out.println("HI");
} //doesn't work
%>

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>