Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Rendering a page handling a File Download Dialog causes page state to belost

Reply
Thread Tools

Rendering a page handling a File Download Dialog causes page state to belost

 
 
Nishi Bhonsle
Guest
Posts: n/a
 
      02-25-2004

On a webserver, I have a set of client pages that are based on XML technology with events triggered on each action, these events are written in java.
One of the pages say A has a link say link1 which when clicked prompts for a File Save As Dialog box. I observe that when the file is saved and control is returned back to the page A, the state of that page is lost.

ie I have to login some credentials(such as username/passwd) in order to be directed to page A, those credentials are saved on Page A. There are other links on Page A which when clicked get directed to different other pages and it is possible to come back to Page A without losing the state. The state or the session information is lost only in the case when the File Save As Box is called.
Does anyone know of how I could save the session state or preserve the session state through java?

The java class FileDownloadRenderer supports streaming binary and text.It has methods to handle a given input stream, the stream
will be closed once the page has rendered and for a given reader, the mimeType should include the character set encoding used, if applicable. The reader will be closed once the page has rendered.


The following code renders the page A

public void renderPage(BajaContext context,Page page) throws IOException, ServletException
{
System.out.println("in render page");

if ((_stream == null) && (_reader == null))
{
//BajaHttpUtils.sendNotFoundError(context);
return;
}
else
{
HttpServletResponse response = context.getServletResponse();

response.setContentType(_mimeType);
if (_fileName != null)
{
response.setHeader("Content-disposition",
"attachment; filename=" + _fileName);
}

if (_size >= 0)
{
response.setContentLength(_size);
}

if (_stream != null)
{
OutputStream out = response.getOutputStream();
try
{
byte[] buffer = new byte[8192];
int bytesRead = 0;
while (bytesRead >= 0)
{
bytesRead = _stream.read(buffer);
if (bytesRead > 0)
out.write(buffer, 0, bytesRead);
}
}
finally
{
out.close();
_stream.close();
}
}
else
{
Writer out = response.getWriter();
try
{
char[] buffer = new char[4096];
int charsRead = 0;
while (charsRead >= 0)
{
charsRead = _reader.read(buffer);
if (charsRead > 0)
out.write(buffer, 0, charsRead);
}
}
finally
{
out.close();
_reader.close();
}
}
}
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening ASP page causes file download dialog instead Neil Rossi ASP General 5 02-07-2006 09:54 PM
IE6 SP1 rendering vs IE6 SP2 rendering Peter Mount HTML 4 01-31-2006 08:01 AM
Force Open .OFT file in Outlook do not show File Download Dialog Kele ASP .Net 0 07-14-2005 06:27 AM
Strange characters displayed in file name - File Download Dialog - IE Daniel Cardoso ASP .Net 1 09-24-2004 05:19 PM
Postback causes 100=Continue, causes double download prompt? Xavier Osa ASP .Net 0 01-09-2004 11:17 AM



Advertisments