Servlet I/O Stream problem: cannot write into file, error 500

I am a new Java developer and now, I am facing a problem regarding the error 500. I try to grab records from a table with a date as a constraint. There are two servlets involed: a) saveRecord and b) getRecord. Servlet getRecord will grab data from a database while another servlet, saveRecord will get the data from servlet getRecord and save it into a file. The codes are as below:
=========================================================================================================================================
// Servlet Name : saveRecord
BufferedInputStream instr     = null;
BufferedOutputStream outstr     = null;
PostMethod http_post          = null;
http_post = new PostMethod("getRecord");
http_client.executeMethod(http_post);
instr     = new BufferedInputStream(http_post.getResponseBodyAsStream());
outstr     = new BufferedOutputStream(new FileOutputStream("c:\student.csv"), false));
int byte_at;
while (-1 != (byte_at = instr.read())) {
     outstr.write(byte_at);
=========================================================================================================================================
// Servlet Name : getRecord
ServletOutputStream out     = response.getOutputStream();
StringBuffer str_buf     = new StringBuffer();
str_buf = generateStudentAc();
out = response.getOutputStream();
FileStream(out, response, str_buf);
// Function Called
private StringBuffer generateStudentAc() {
     StringBuffer str_buf = new StringBuffer();
     String date = "2000-01-01";
     statement = connection.createStatement();
     resultset = statement.executeQuery("SELECT NAME, ADDRESS FROM STUDENT WHERE DATE>'" + date + "';
     // Write column headers               
str_buf.append("NAME,ADDRESS");
String data_row;
while (resultset.next()) {
          data_row = "\n";
          data_row += "\"" + resultset.getString("STUDENT") + "\"";
          data_row += ",\"" + resultset.getString("ADDRESS") + "\"";
          // Write row
          str_buf.append(data_row);
     return str_buf;
// Function called
private void FileStream(ServletOutputStream out, HttpServletResponse response, StringBuffer str_buf) {
     BufferedOutputStream buf_out = null;
// Create input/output streams
     buf_out     = new BufferedOutputStream(out);
     int length     = str_buf.length();
     // Read/Write
     for (int i = 0; i < length; i++) {
          buf_out.write(str_buf.charAt(i));
=========================================================================================================================================
Then, the result will be post back to a JSP page. It didn't work when the records in database growing bigger ( > 100 000 records) but works nice while the records are still in a small quantities ( < 20 000 records). It seems that no record can be inserted into the file and the JSP page becomes blank. When I opened the csv file, I found a message"Error 500:" inside it.
Hope you all experts can help to figure out this problem. TQ

I am amatuer in Java Programming, so I don't know how to implement serializable interface but I will look through it.
However, as I mention before, the code run perfectly if there are not much records un the table. But once there are more and more table added in (> 1000 000 records) in the table, it becomes unstable - sometime it works but most of the time it doesn't. So, I didn't find any different event I replaced the code with String date = "=2000-01-01".
Anyway, thanks for your help.

Similar Messages

  • REP-50127 Cannot write into file

    Our situation:
    DB Oracle 10.2.0.3
    Reports server version: 10.1.2.0.2
    We are generating reports in PDF and storing them in the Oracle OCM (previous IFS) system.
    Once in a while we get an error.
    The report trace gives the following:
    [2010/9/29 7:10:9:739] Exception 50127 (): Cannot write into file Invoicexxx.PDF
    oracle.reports.RWException: IDL:oracle/reports/RWException:1.0
    at oracle.reports.utility.Utility.newRWException(Utility.java:758)
    at oracle.reports.utility.Utility.copyFile(Utility.java:469)
    at oracle.reports.server.DesFile.sendFile(DesFile.java:85)
    at oracle.reports.server.Destination.send(Destination.java:484)
    at oracle.reports.server.JobObject.distribute(JobObject.java:1594)
    at oracle.reports.server.JobManager.updateJobStatus(JobManager.java:2332)
    at oracle.reports.server.EngineCommImpl.updateEngineJobStatus(EngineCommImpl.java:134)
    at oracle.reports.server._EngineCommImplBase._invoke(_EngineCommImplBase.java:94)
    at com.sun.corba.se.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:353)
    at com.sun.corba.se.internal.iiop.ORB.process(ORB.java:280)
    at com.sun.corba.se.internal.iiop.RequestProcessor.process(RequestProcessor.java:81)
    at com.sun.corba.se.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:106)
    [2010/9/29 7:10:9:739] State 56016 (JobManager:updateJobStatus): Job 642218 status is: Executed successfully but there were some errors when distribute the ou
    tput
    REP-50159: Executed successfully but there were some errors when distribute the output
    REP-50127: FILE : Cannot write into file Invoicexxx.PDF
    [2010/9/29 7:10:9:740] State 56004 (EngineInfo:setState): Engine rwEng-1 state is: Ready
    [2010/9/29 7:10:9:741] Exception 50159 (): Executed successfully but there were some errors when distribute the output
    oracle.reports.RWException: IDL:oracle/reports/RWException:1.0
    at oracle.reports.server.JobManager.runJobInEngine(JobManager.java:1110)
    at oracle.reports.server.ExecAsynchJobThread.run(ExecAsynchJobThread.java:54)
    [2010/9/29 7:10:9:741] Exception 50159 (): Executed successfully but there were some errors when distribute the output
    oracle.reports.RWException: IDL:oracle/reports/RWException:1.0
    at oracle.reports.server.JobManager.runJobInEngine(JobManager.java:1110)
    at oracle.reports.server.ExecAsynchJobThread.run(ExecAsynchJobThread.java:54)
    There is enough diskspace available so that's not the issue.
    Does anybody know what triggers the error and how we can avoid it?
    Edited by: vccservice on Sep 30, 2010 11:02 AM

    no freespace in the tablespace is also the reason for this error

  • FileWriter Problem, cannot write a file larger than 8K

    Hi,
    My servlet write 2 files. The problem is the second file I wrote cannot exceed 8K
    PrintWriter os = new PrintWriter(new FileWriter("temp\\q0.dat"));
    os.close();
    PrintWriter os2 = new PrintWriter(new FileWriter("temp\\q1.html"));
    I have the following write statement:
    os2.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
    os2.println("<HTML><HEAD><TITLE> Q1 </TITLE>");
    os2.println("</HEAD><BODY><FORM METHOD=POST ACTION=\"\"><BLOCKQUOTE><TABLE border=\"0\">");
    The problem is if I use this kind of statement, some println statement not appear in the destination file q1.html (those lines at bottom)
    then if I turn these 3 statement and change to 1 print statement, more letter write to q1.html?
    Pls tell me what's wrong with my program! Thank you

    You didn't close the second PrintWriter after you finished using it?

  • 9.2.0.6 runInstaller cannot write into its own installation directory

    I would like to install the 9.2.0.6 patchset on a freshly installed 9.2.0.4_linux_x86_64 (AMD). The system is RedHat EL AS 3. I have installed j2re1.4.2_07 (because the Java brought by Oracle does not even start the VM ...) and edited the ./install/oraparam.ini to use our own JRE.
    runInstaller tells me that all system requirements are met. But - alas - OUI says that it cannot write into the directory that it created itself (tmp/OracleInstall...). The rights matrix of this directory is drwxr-xr-x oracle oinstall, even if I set umask to 0000. There are several GB free.
    The last message is
    : file or directory not found
    What is going on here (or rather what isn't)? What file is OUI looking for?
    Thanks in advance for kind replies

    Ivan,
    the rights for /tmp were already rwxrwxrwt. Even if I remove the sticky bit, the error remains. I have the strange feeling that this is not a rights problem. Do you have any idea what
    : file or directory not found
    is supposed to mean? What file is OUI looking for? Does OUI 10.1.0.3.0 check for temporary files of other OUI versions (e.g. OUI 2.2.0.18.0 bundeled with Oracle 9.2.0.4)?
    I think I will start from scratch: remove and reinstall 9.2.0.4 and then try the patch installation again.
    Frank

  • Trying to install itunes on my new windows 8 laptop and getting an error message cannot write to file?

    error message cannot write to file when trying to install itunes on windows 8 laptop.

    Hi Stacy,
    Welcome to Apple Support Communities.
    Take a look at the article below, it provides a lot of great tips that will resolve most iTunes installation issues.
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/ht1926
    If you run into any issues, just reply with details about the step you're on and what you're seeing.
    -Jason

  • I'm trying to download my Master CS6 onto a new hard drive because my old one crashed and I keep getting a message saying " Cannot write the file" or "I don't have permission to access the requested resource." ? What does this mean?

    I'm trying to download my Master CS6 onto a new hard drive because my old one crashed and I keep getting a message saying " Cannot write the file" or "I don't have permission to access the requested resource." ? What does this mean?

    Yes- it is a Mac. I went through adobes system requirements and re- downloaded supportive software. The notice seems to happen near the end of the down load with the messages above. I'll look into your suggestion. Thank you- appreciated.

  • Cannot write configuration file

    Hello,
    I have a problem loading up a project I have taken over from some one else. I need some guidance as I can't seem to find the solution. However im not that familiar with .NET or MVS as I once
    was. The message I get is as follows :-
    Microsoft Visual Studio
    Creation of the virtual directory localhost:49623/ failed with the error: Filename: \\?\C:\Users\firstname.surname\Documents\IISExpress\config\applicationHost.config
    Error: Cannot write configuration file
    However I have checked the permissions and can't see anything obvious. Under guidance from another developer I have also updated :-
    www.nuget.org/
    and
    www.nuget.org/packages/Microsoft.AspNet.Mvc
    I am using a Windows 7 enterprise edition Dell Lattitude laptop. With MVS as follows
    Microsoft Visual Studio Professional 2012
    Version 11.0.50727.1 RTMREL
    Microsoft .NET Framework
    Version 4.5.50938
    Installed Version: Professional
    Microsoft Visual Studio Tools for Applications 2012   04938-088-1153812-02395
    Microsoft Visual Studio Tools for Applications 2012
    Office Developer Tools   04938-088-1153812-02395
    Microsoft Office Developer Tools
    Team Explorer for Visual Studio 2012   04938-088-1153812-02395
    Microsoft Team Explorer for Visual Studio 2012
    Visual Basic 2012   04938-088-1153812-02395
    Microsoft Visual Basic 2012
    Visual C# 2012   04938-088-1153812-02395
    Microsoft Visual C# 2012
    Visual C++ 2012   04938-088-1153812-02395
    Microsoft Visual C++ 2012
    Visual F# 2012   04938-088-1153812-02395
    Microsoft Visual F# 2012
    Visual Studio 2012 Code Analysis Spell Checker   04938-088-1153812-02395
    Microsoft® Visual Studio® 2012 Code Analysis Spell Checker
    Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.
    The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V.
    All rights reserved.
    Visual Studio 2012 SharePoint Developer Tools   04938-088-1153812-02395
    Microsoft Visual Studio 2012 SharePoint Developer Tools
    NuGet Package Manager   2.8.60318.667
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit docs.nuget.org/.
    PreEmptive Analytics Visualizer   1.0
    Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
    SQL Server Analysis Services  
    Microsoft SQL Server Analysis Services Designer
    Version 11.0.5058.0
    SQL Server Data Tools   11.1.20627.00
    Microsoft SQL Server Data Tools
    SQL Server Integration Services  
    Microsoft SQL Server Integration Services Designer
    Version 11.0.3436.0
    SQL Server Reporting Services  
    Microsoft SQL Server Reporting Services Designers
    Version 11.0.3436.0
    Web Developer Tools   1.0.30710.0
    Microsoft Web Developer Tools contains the following components:
    Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
    Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
    Web Form Templates: Includes the default templates for Web Form Applications.
    Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.

    I see some others have had success by removing encryption on the IISExpress folder and removing the Read Only attribute as well.
    See this post for details.
    Others have had success by doing the following:
    - Run Command Prompt (cmd) in Admin Mode
    - Enter the following command: DISM /Online /Cleanup-image /Restorehealth
    ...as detailed here.

  • Scanning with Preview - "cannot write to folder" error

    I was scanning some photos yesterday using my epson 3170 scanner into Preview.
    These scanned & saved OK.
    then I installed a couple of Apple updates - one was the latest OS X security update and a java update.
    I then scanned something else and now I get a "cannot write to folder" error message preventing me from saving the scanned image (to the same folder I was saving the others to earlier).  I can save files to the same folder using other apps so there is nothing wrong with the drive or folder permissions.
    I scanned the image otthe desktop and moved the file to the folder I wanted.
    If I use ImageCapture it works OK as well.
    Any ideas why Preview won't let me save the images?

    Check the protections.  A command such as ls -ale@ or ls -aled@ would be typical for checking that.   I'd guess the files aren't writeable by the web server.  This'll probably be a chown and possibly a chmod command to bring the settings on the errant log(s) into agreement with the other settings on the other Apache web server logs that are being written.
    FWIW, I'd use zdump or cat and pipe the log contents elsewhere if I wanted to write to them.  But if you're resetting the logs, there's a rollover script around (the one that runs automatically on OS X, and I'm unfortunately drawing a blank on the name; it moved from the /etc/periodic stuff over to launchd a while back), or write your own short script that rolls the files and leaves the appropriate owner and permissions settings.
    There's an intro to the Mavericks Apache file set up at /library/server/web/config/apache2/readme.txt

  • Cannot write class file...

    I have no idea what this means. This app was running just
    fine. Then wham.
    Here is the error message:
    Errors reported by Java compiler: Found 1 semantic error
    compiling
    "D:/CFusionMX/wwwroot/WEB-INF/cfclasses/cfApplication2ecfm855244706.java":
    1. public final class cfApplication2ecfm855244706 extends
    coldfusion.runtime.CFPage{ <-------------------------> ***
    Error: Cannot write class file "cfApplication2ecfm855244706.class"
    because that name conflicts with the name of the class file
    "cfapplication2ecfm855244706.class" in directory "cfclasses". This
    is illegal because file names are case-insensitive in this system.
    If anyone can tell me where to look and what to do here, I
    would be very grateful.
    Thanks,
    Lee

    Try clearing out your cfclasses directory which is located on
    your machine at D:\CFusionMX\wwwroot\WEB-INF\cfclasses. Then
    restart CF.

  • Sign on problems within Elements 10; plus cannot backup writing files error with file catalog.pse10db.  No indication what the problem is.  How do I get adobe help with these problems?

    Sign on problems within Elements 10; plus cannot backup, writing files error with file catalog.pse10db.  No indication what the problem is.  How do I get adobe help with these problems?

    Sign on problems within Elements 10; plus cannot backup, writing files error with file catalog.pse10db.  No indication what the problem is.  How do I get adobe help with these problems?

  • Satellite P500/01R reads data but cannot write data files to CD

    I recently bought a Satellite P500/01R laptop. I am able to read a data CD but cannot write data files to CD. The CD is read/write.
    Any ideas?

    Hi
    Did you try different burning software?
    Im using the Nero and in my opinion one of the best burning applications.
    There I can choose between CD, DVD, DL or Blueray (only possible if CD/DVD drive supports this too.)
    Did you also check different CDs from different manufacturers?
    You should do this since not all disks are 100% compatible.
    I had many issues with different CD or DVD in most cases it was an compatibility issue I tested TDK and these kind of disk is compatible with my CD/DVD drive
    Im using the R standard.

  • Keep getting Cannot save library file error -50 message on my PC

    I keep getting "cannot save library file error -50 when I open up iTunes on my PC
    Won't download music purchased on iPhone4 to iTunes in my PC

    Same issue here. Running Windows Vista Home Premium Edition and newest version of iTunes. Normally happens when I am ripping a CD into iTunes and by chance multi task or the screen saver kicks in.
    What ***** is if you walk away while ripping a CD(because it takes 3 times as long in iTunes vs any other ripper), and it will halt your ripping until you click "ok". I have not tried the "dont tell me again" check box just in case it is a problem I need to know about. This happened about 2 or 3 days after upgrading to Vista and I got an empty library the next time I opened the library. Somehow it got corrupted. Luckily I back up the xml file and just restored that one file from last back up.
    (off subject but also getting the maxed our processor still in the newest version for Windows Vista. Wish they would fix that!)

  • Ebook error message: "Fail to write destination file error"

    I am attempting to transfer ebooks (checked out via my library's ebook consortium) from Adobe Digital Editions to my Nook. I have done this in the past with no issues, but recently I have been getting the following error message: "Fail to write destination file error".
    I know the issue is NOT lack of space on my Nook (I cleared it of all info and still received the error message).

    I had this problem as well, and after doing some research via google (because I found NOTHING helpful in adobe forums), I found the problem....my Nook was full.  I had no idea this was even possible!  But, I borrow a lot of library books, and didn't realize that after they expire, they are still taking up space on my Nook.  Here's how to check: plug your Nook into your computer, go to file manager (right-click the start button in Windows), find the Nook drive and right click, choose properties.  This should show you a pie chart of used/free space on your Nook.  If this is the case, you need to remove some files from your Nook.  For me, I had to find the Digital Editions file and delete all the thumbnails and actual files for the library books.  If it's booked you've purchased, perhaps you need to archive some books.  Hope this helps!

  • Premiere Pro CS5: please help problem with importing a file error output "there was an error decompressing audio or video"

    please help problem with importing a file error output "there was an error decompressing audio or video"

    this is related to what adobe program/version?

  • PS CC: Camera Raw filter gives "cannot parse your files" error

    Hi
    I can open files fine in Photoshop CC, but if I try to use the Camera Raw filter, I get the "file format module cannot parse your files" error. This only happens with larger TIFFs, say 300 MB or so - 70 MB files work fine. I have a fast machine running Windows 7 with 12GB of RAM, so I would expect to have enough space, but maybe it isn't configured properly in PS preferences?
    Thanks for any help,
    Peter

    siskin11 wrote:
    Hi
    I can open files fine in Photoshop CC, but if I try to use the Camera Raw filter, I get the "file format module cannot parse your files" error. This only happens with larger TIFFs, say 300 MB or so - 70 MB files work fine.
    300MB Tiff seems like a large files size for a Tiff which leads me to believe its a layered Tiff.  ACR does not have Layers support try opening the Tiff file in Photoshop not through ACR to see it there are layers. If there are target  all of them and convert to a smart Object then try ACR as a filter. A smart object is a single layer in Photoshop.

Maybe you are looking for