File Downloading/Save problem

2002-04-03 Thread ssmtech

Hello All,
I have written a code to download a Text file from Server to Local Disk.But the problem
is that when i click a Button in the JSP page through which the downloading of file is 
done,opens a Dialouge Box with the "Save To Disk " option selected.when i go for the 
Save 
option the Text Field shows me a Wrong Filename("downloadFile.htm")which is not 
the 
File i want Download.I want to Download "1003-3.txt"
Also when i go for the "OPEN" option and click on "OK" the Dialouge Box Opens again 
with the "Save To Disk" option selected,when i click on "OK" the Text Field of the 
Dialouge Box Shows the CORRECT Filename("1003-3.txt").when i click OK the File 
gets DOWNLOADED but with "NO CONTENTS".

The snippet of code is .


public HttpServletResponse doDownloadFile(HttpServletRequest req,HttpServletResponse 
res)
throws ServletException,IOException {

String fname = "1003-3.txt";
res.setContentType("application/binary");
res.setHeader("Content-Disposition","attachment; filename=\""+fname+"\";");

ServletOutputStream stream = null;
try {
stream = res.getOutputStream();
BufferedInputStream bif = new BufferedInputStream(new FileInputStream(fname)); 
int data;
while(( data = bif.read()) != -1) {
stream.write(data);
stream.flush(); 
}
bif.close();
stream.close();
return res;
} catch(Exception e) {
}
finally {
if (stream != null)
stream.close();
return res;
}

}




Can Anybody Help me out with the problemPlease it is URGENT!!
Thanks a MILLION in Advance

==To 
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Re: File Downloading from server to local disk

2002-03-31 Thread ssmtech

Hello Vikramjit Singh,

 Thank you very much for your co-operation.
 I am experiencing a strange problem.The File which i want to Download
is
 "1003-3.txt",but when i try to download this file the Dialouge box
window ask me for
 two options "Open or Save to Disk " .If i go for "Open" ,the File
"Opens" Properly but
 when i try to "Save To Disk" the File which is getting Downloaded
is
 "downloadFile.htm".

 The code is as follows.

 try
{

  File f= new File("c:/ssmtech/download/customers/1003-3.txt");

  res.setContentType("text/plain");
  res.setContentLength((int) f.length());

  res.setHeader("Content-Disposition","attachment; filename=\"" + f+"\"");

  FileInputStream fis = new FileInputStream(f);
  ServletOutputStream os = res.getOutputStream();

  int i;
  while ((i = fis.read()) != -1)
   {
os.write(i);

   }
   fis.close();
   os.close();
   return res;
  }
 catch(Exception e)
   {
 System.out.println("the exception is..."+e);
 return res;
   }
   }



 Can you please help me out with this problem.Thanks in advance.

Regards
Sameer





- Original Message -
From: "Vikramjit Singh" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 28, 2002 5:09 PM
Subject: Re: File Downloading from server to local disk


> hi,
>
> I also had the problem in downloading the file. I tried it this way.
>
> First, set the response's content type to APPLICATION/OCTET-STREAM. This
> value is not case-sensitive. Then, add an HTTP response header named
> Content-Disposition and give it this value:
>
> attachment; filename=theFileName
>
>
> Where "theFileName" is the default name for the file that appears on the
> File Download dialog box. This is normally the same name as the file, but
> does not need to be.
>
> Finally, this page demonstrates how to send a file to the user's browser:
>
> // fetch the file
> String filename = "companySecret.txt";
> String filepath = "C:\\";
> response.setContentType(
> "APPLICATION/OCTET-STREAM");
> response.setHeader("Content-Disposition",
> "attachment; filename=\""
>  + filename + "\"");
>
> java.io.FileInputStream fileInputStream =
> new java.io.FileInputStream(filepath
>  + filename);
>     int i;
> while ((i=fileInputStream.read()) != -1) {
> out.write(i);
> }
> fileInputStream.close();
> out.close();
>
> I had tried it on tomcat. Hope it helps.
>
> Regards,
> Vikramjit Singh,
> Systems Engineer,
> GTL Ltd.
> Ph. 7612929-1031
>
>
> -Original Message-
> From: ssmtech [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 28, 2002 3:11 AM
> To: [EMAIL PROTECTED]
> Subject: File Downloading from server to local disk
>
>
> Hello All
> I have code for downloading a text file a server to the local
> system in a JSP page and not as a seperate Servlet,but it is giving me a
> "IllegalStateException" the snippet of the code is
>
>  String fname1 = ""+user.getBusinessId();
>  String fname2 = ""+user.getAccountId();
>  String fname = fname1+"-"+fname2+".txt";
>  response.setContentType("text/plain");
>  response.setHeader("Content-Disposition","multi-part
> attachment;filename=\""+fname+"\";");
>  ServletOutputStream stream = null;
>  try {
>  BufferedInputStream bif = new BufferedInputStream(new
> FileInputStream("c:/ssmtech/download/customers/"+fname));
> int data;
> stream = response.getOutputStream();///  It is giving me a
> IllegalStateException  out here.
> while(( data = bif.read()) != -1) {
> stream.write(data);
>  }
> bif.close();
> stream.close();
>   } catch(Exception e) {
>   }
>  finally {
> if (stream != null)
> stream.close();
>   }
>
>
>
> I am working on a J2EE Application Server.and on EJB..
> Please anybody can help me out with.this .it is Urgent
>
>
> Sam
>
>
===

File Downloading from server to local disk

2002-03-28 Thread ssmtech

Hello All
I have code for downloading a text file a server to the local system in a 
JSP page and not as a seperate Servlet,but it is giving me a  "IllegalStateException" 
the snippet of the code is 

 String fname1 = ""+user.getBusinessId();
 String fname2 = ""+user.getAccountId();
 String fname = fname1+"-"+fname2+".txt";
 response.setContentType("text/plain");
 response.setHeader("Content-Disposition","multi-part 
attachment;filename=\""+fname+"\";");
 ServletOutputStream stream = null;
     try {
 BufferedInputStream bif = new BufferedInputStream(new 
FileInputStream("c:/ssmtech/download/customers/"+fname)); 
int data;
stream = response.getOutputStream();///  It is giving me a 
IllegalStateException  out here.
while(( data = bif.read()) != -1) {
stream.write(data);
 }
bif.close();
stream.close();
  } catch(Exception e) {
  }
 finally {
if (stream != null)
stream.close();
  } 
   


I am working on a J2EE Application Server.and on EJB..
Please anybody can help me out with.this .it is Urgent 


Sam

==To 
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com



Retrieving Multiple values of single Parameter

2002-01-08 Thread ssmtech



Hello All,
 
   I have a JSP 
page with a list of Customers along with there respective 
Checkboxes.   The values contained in the 
Checkboxes are CustomerId's of the respective 
Customers.   After checking the Checkboxes 
i have a Link "Actions" which opens a new Page. 
   I am trasfering the checked 
values(CustomerId's) to this new Page through the 
"URL".   For Example,  
URL=CustomerId=1&CustomerId=2&CustomerId=3... and so on.
 
   So my 
problem is How do I catch Multiple Values of a single parameter to this 
    new page.Also i need to Submit 
these values in the Backend.
 
Sameer


Problem while displaying pages in Iframe

2001-04-24 Thread SSMTech

Hello friends,

I have a Customermain.jsp  page which is server generated. In this page
there are four iframes."src" parameters referencing to four different
pagesnamely :
1 MainInfo.jsp
2 Addresses.jsp
3 Contacts.jsp
4 MiscInfo.jsp
These pages are also generated dynamically.
After deploying on the j2ee server, the first time Customermain page
displays the above pages correctly in their corresponding positions.But on
refreshing the CustomerMain page or calling it again for another customer,it
gives erratic result. For eg : It shows address page at Contactpage location
or Contact page in another location or the same page in all four locations.

Please respond  as soon as possible,

SSMTech

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets