• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

IllegalStateException

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am downloading a file from the server and saving it to the client disk.
I am using a jsp file that cles a Java function.
He makes it but gives the following error:
"2001-12-13 08:44:27 - Ctx( /PS2 ): IllegalStateException in: R( /PS2 + /save.jsp
+ null) OutputStream is already being used for this request"

In the Java API, IllegalStateException is a Runtime Excepttion, so i think the problem is in Java. However i don't understand.
I closed the outputstream and also flushed it.

Can you help me? I really don't know was is wrong!!!

Thanks
Claudia
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you explain how you are trying to write to the client disk from a JSP? Are you trying to send something back through the "out" variable? Why not show a little code?
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This isn't really an EJB issue so I am sending this to the JSP forum.
 
Claudia Vaz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
Here is the code.
In a jsp file i call a java method:
"<jsp:useBean id="downloadSave" scope="page" class="DownloadSave" />
<%
String nameFichEur = request.getParameter("nomeFile");
downloadSave.doSave(nameFichEur,response);
%>"
The code of the class downloadSave is:
"import java.io.*;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletInputStream;
public class DownloadSave
{
public void doSave(String nameFichEur, HttpServletResponse res)throws ServletException, IOException
{

String pathFichEur = "c:\\jakarta-tomcat-3.2.3\\webapps\\PS2\\WEB-INF\\classes\\uploaddir\\" + nameFichEur;
System.out.println("nameFichEur: " + nameFichEur);
System.out.println("pathFichEur: " + pathFichEur);
//res.setContentType("application/x-filler");
res.setContentType("application/txt");
res.setHeader("Content-Disposition","attachment;filename=" + nameFichEur );

try
{
FileInputStream fileInput = new FileInputStream(pathFichEur);
int numOfBytes = fileInput.available();
byte byteArray[] = new byte[numOfBytes];
int nextByte = fileInput.read(byteArray);
fileInput.close();

OutputStream outStrm = res.getOutputStream();
outStrm.write(byteArray);
//outStrm.flush();
outStrm.close();
}
catch(IOException ioe)
{
System.out.println("download:file input exception");//..........
//ioe.printStackTrace();
}
catch(Exception e)
{
System.out.println("download: exception");//..........
}
}
}"
I hope you can help me!!!
Thanks
Claudia Vaz
 
Claudia Vaz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again
I forgot. I am using Tomcat.
Also, in tha Java class i tried to cath the exception using the following code:
"catch(IllegalStateException ise)
{
System.out.println("illegalstateexception: " + ise.getMessage());
ise.printStackTrace();
}"
and in Tomcat window the system.out.println doesn't appear.
Thanks
Claudia
Claudia
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out should write to the browser's console.
------------------
Bosun
SCJP for the Java� 2 Platform
 
reply
    Bookmark Topic Watch Topic
  • New Topic