Writing into a file in clients' machine from a jsp application

is it possible to write some data fetched from database into a .CSV file on the clients machine from an JSP application?
signed applets is one possibility , any other possibilities are there?
thanks
Mohammed Rafeeq([email protected])

* @(#)ExcelServlet.java
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.util.*;
import java.sql.*;
* @author M.Rajendra
public class ExcelServlet extends HttpServlet {
     public void init(ServletConfig config)throws ServletException{
          super.init(config);
     } // end of init method
     public void doGet(HttpServletRequest req, HttpServletResponse res)
                                             throws ServletException,IOException     {
          doPost(req,res);
     } // end of doGet method
     public void doPost(HttpServletRequest req,HttpServletResponse res)
                                             throws ServletException,IOException     {
          HttpSession session = req.getSession(true); // session is already created at loginscreen
          OutputStream oout = res.getOutputStream();
          res.setHeader("Content-disposition","filename=excel.csv");
               //res.setContentType("application/octet-stream");
               FileInputStream fis = new FileInputStream("D:\\JRun3.1\\servers\\default\\default-app\\WEB-INF\\classes\\test.csv");
               //here i am reading a csv file, we can output whatever format and set filename of ours
               byte[] buf = new byte[1024];     //get from statics
               int bytesRead = 0;
               while((bytesRead = fis.read(buf)) != -1){
                    oout.write(buf,0,bytesRead);
               oout.close();
               fis.close();
     }//end of doPost method
     public void destroy()     {
     }// end of destroy
} //end of ExcelServlet class

Similar Messages

  • Save file on client machine on the web.....

    Hi,
    I have a Form Application C/S 6i where I create a file using Get_File_Name, TEXT_IO.fopen .... etc. This application it's OK. The problem is when I load the application on AIS9i. The application don't load never. I must create and save a file on client machine when I use application on the web. What Can I do? Is This operation possible without radical change of the code source?
    Thanks

    Erik,
    actually this project is under the leadership of the same author that created d2kwutil. It is too early to tell what exactly will be in this package and most likely we will release things step by step as they finish. However, you canuse this thread for a wishlist of functionality and I will pass it to the project lead. The implementation will be both POL/SQL and Java (as Java is the only way for us to access the client side in teh Web). The project target is sometime mid of next year. As said, the project hasn't really started yet so it is too early to speculate on what will make it in and when this will be delivered.
    Frank

  • How to load a excel sheet on the client machine from jsp

    hai all,
    I want an excel sheet to be opened like "c:\excelsheet.xls" on the client machine from my JSP so that i can send the out put of my jsp to it.i will press a button on jsp and i want the query out put in the excel sheet. if it is already opened then it has to be closed and reopened with new data, the old data has to be lost.
    can any one help me out....
    Thanks for any help...
    regards,
    ravikiran

    Hai friend,
    you add mime type in web.xml
    for example,
    <mime-mapping>
    <extension>xls</extension>
    <mime-type>application/excel</mime-type>
    </mime-mapping>

  • Creation of CSV file on client machine with data from forms

    Hi,
    My requirement is to generate a CSV file(or .XLS) on the client machine ie local drive with the details shown in a form.
    Oracle version -
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production.
    I have searched the web for last couple of days and got to know that TEXT_IO is to be used to generate files on client machine. However, when I tried TEXT_IO, it was not able to generate the file on client rather it was able to generate on database server. After further browsing on this, there was a link which said that we need to use CLIENT_TEXT_IO to generate file on client side. For this, i was required to subclass the webutil.pll which i did and corrected the code to use CLIENT_TEXT_IO. The form was unable to compile and was not able to find "webutil_core" package.
    I am very confused with the disparity in the information available on the web as in what to use to generate a file on client side. If anyone has use it in the past, can he/she please detail what to use to get things sorted.
    Thanks,
    R

    Oracle version - Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production. >
    So, what is your FORMS version. This is more important than your database version.
    My requirement is to generate a CSV file(or .XLS) on the client machine ie local drive with the details shown in a form. Depending on your Forms version, you would use TEXT_IO (if Forms 6i running in Client/Server mode) or WebUtil (if Forms 9i or higher).
    I'm going to guess that you are at least using Oracle Forms 9i since you stated that your attempt at using TEXT_IO produced a file on the DB server.
    There is more to using WebUtil than just attaching the WEBUTIL.PLL. If you had performed a simple search of the Forms Help System would have found numerous WebUtil topics to include: Introduction to WebUtil, Configuring WebUtil, Using WebUtil in Your Applications and the WebUtil User's Guide. If you have Oracle Forms release 10g or higher, WebUtil is included when you installed Forms, however, you do need to configure your installation to use WebUtil and you must download the Java COM Bridge (jacob.jar) from Source Forge. Take a look at the Configuring WebUtil Forms Help topic to find out which version of the Java COM Bridge you will need to download.
    After you have successfully configured WebUtil, take a look at the Using WebUtil in Your Applications topic to find out how to implement WebUtil in a form.
    Searching the Internet for answers is great, but don't forget the look at the Forms Help System because the majority of your questions can be answered there. :)
    Lastly, configuration of WebUtil is primarily done on your Application Server (AS). However, if you plan to perform preliminary runtime testing by running your Form from the Forms Builder, then you will configure your local runtime to support WebUtil as well as configure your AS. The steps are exactly the same. A common mis-step is to skip a step during the configuration because you don't think the step applies. Take a look at the Forms Help Runtime Setup Checklist topic for a list of step you need to complete in order to enable WebUtil.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • OSB cluster --reading a writing into a file

    Dear All,
    I have a requirement in which my first OSB service s writing into a file(In a clustered environment).So in this case some of the files are being written in managed_server1 while some of the files are getting written in managed_server2.
    My second OSB service has to poll those files.Now as we know while polling,we have to define one target server(managed server).So this service will only be able to poll from one managed server.Is there any way it can poll from both the managed servers?

    Hello Deepthi,
    Can you please explian what is meant by shared storage as i am not aware of that.From shared storage, I meant common mounted/mapped file system.
    We have 2 managed servers on two different physical machines and we are using clustered environment.In this case you have two option -
    1. Use unique endpoint & mask combo for both the proxies and make sure that all the servers in the cluster have access to the staging directory of the polling manged server (by mounting/mapping the file system appropriately).
    2. Create a shared storage by mounting/mapping the file system for business services to put file and have a single proxy to poll that shared storage. Again all managed server need to have access to the staging directory of the polling manged server.
    You may like to refer metalink note ID 965135.1
    To understand how to achieve HA in this case, please refer -
    OSB10gR3:High-availbility of file protocol based proxy service
    Regards,
    Anuj

  • Not able to create a text file in Client Machine using Forms 10g

    Hi - I'm mot able to create a text file in Client Machine using Forms 10g. I'm getting error when system executes the bolded line.(i.e. CLIENT_TEXT_IO.FOPEN). During run-time system is throwing "ORA-06508: PL/SQL: could not find program unit being called".
    I had attached webutil.pll in the form.
    Please advise me.
    DECLARE
    l_Temp CLIENT_TEXT_IO.FILE_TYPE;
    LC$Name Varchar2(100) ;
    LC$Fic Varchar2(100) ;
    LN$Lines Pls_integer := 0 ;
    LC$Line Varchar2(4000) ;
    Cursor C_CUR Is
    Select * From TEST_TEXTIO where rownum <= 50;
    BEGIN
    LC$Name := 'tmp_file.txt' ;
    LC$Fic := 'c:\temp\tmp_file.txt';
    Begin
    l_temp := CLIENT_TEXT_IO.FOPEN( 'C:\temp\tmp_file.txt', 'W');
    Exception
         when others then
         message( 'OPEN FILE ERROR ' || LC$Fic ||sqlerrm );
         display_error;
         raise form_trigger_failure;
    End ;
    -- Write the lines --
    For Cur In C_CUR Loop
         LC$Line := Cur.CODE || ' -> ' || Cur.COL1 || ',' || Cur.COL2 || ',' || Cur.Col3 ;
         CLIENT_TEXT_IO.PUT_LINE( LF$File, LC$Line ) ;      
         LN$Lines := C_CUR%ROWCOUNT ;
    End loop ;
    -- Close the file --
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;
    Exception
         When others Then
    message('err='||sqlerrm);message(' ');
    display_error;
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;      
         Raise ;
    END;
    Thanks.
    Arun

    Hi ,
    i have one Question though its not related to thos question if some could help me it will be really helpful,
    i have created one program to import and export excel to forms vice versa, if the form is attached with webutil its working fine am using ole2.but i have a new idea if i add this program in menu, it can be used for all the forms attched to that menu, i made program also, but problem am facing right now is if the form is not attched with webutil it will not work so is there possiblity to share my webutil from one form to another form ,so i will keep one form as a interface form in that webutil will be attched ,i can share that webutil to all other forms so that all the forms no need to attach webutil again
    if its possible means please suggest some ideas

  • Open bat file on client machine using webutil

    Hi all.
    I'm on devsuite 10g.
    I want to run a bat file on client machine using client_host function of webutil.
    I have tried first to execute the bat file with mouse double-click in order to check if it is ok, and it works.
    Now I want to execute this file from my form using webutil.
    Here is my code:
    --> with this code I select a file from client machine
    Declare
         LC$Fichier Varchar2(1000):=null ;
         PC$Filtre Varchar2(2000) := '|All files|*.*|' ;
    Begin
         LC$Fichier := WEBUTIL_FILE.FILE_OPEN_DIALOG
         null,
         PC$Filtre,
         'Seleziona un file da caricare'
    If LC$Fichier is not null Then
    :output.apri_file := LC$Fichier ;
    End if ;
    End ;
    --> with this code I execute the file that I have opened
    declare
         cmd varchar2(30000) := null;
    BEGIN
         Cmd := 'cmd /c start "" "' || :output.apri_file || '"' ;
    CLIENT_HOST(cmd);
    END;
    When I execute my form I have this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: ....folder of file opened.
    Can anyone help me to solve this problem??
    Thanks in advance,
    Fabrizio

    Fabrizio Delli Priscoli wrote:
    Hi Tony.
    I have tried to run my bat file with double-click and everything is OK.
    When you say the DOS window opens for few second, is your batch file being executed?? did you see the results??
    The answer in NO for both of your questions.
    If I try to drag and drop the file I have error.
    How can I attach an image to this post, so that you can see the error??
    Thanks,
    FabrizioThis seems like a directory or OS level permission issue on the batch file, What is the error you got when you tried drag and drop the batch file in an DOS window???
    I think you need to upload the image to a site and use the markup for the image, include the full URL of the uploaded file between ! (exclamation marks) something like ! http://../post.gif ! without the spaces.
    Tony
    Edited by: Tony Garabedian on Sep 4, 2008 12:30 PM

  • ORA-48913: Writing into trace file failed

    Hi
    my OS: OUL5x64
    DB: 11.1.0.7
    receive this error in alert.log but could not figure out which parameter to increase.
    Can someone please help.
    Non critical error ORA-48913 caught while writing to trace file
    Error message: ORA-48913: Writing into trace file failed, file size limit [10485760] reached
    the suggestion:
    ORA-48913: Writing into trace file failed
    *Cause:An attempt was made to write into a trace file that exceeds the trace's file size limit
    *Action:increase the trace's file size limit.
    Thanks in advance.

    Hi ,
    I have one more doubt :
    ORACLE_SID=XXXX
    /XXXX/XX/ofaroot/XXXX/diag/rdbms/xxxx/XXXXX/trace
    Non critical error ORA-48913 caught while writing to file "trace /XXXX/XX/ofaroot/XXXX/diag/rdbms/xxxx/XXXXX/trace/XXXX_ora_8218.trc"
    Error message: ORA-48913: Writing into trace file failed, file size limit [10485760]everywhere its written to increase the parameter max_dump_file_size or to relocate the alert log, but as far as i understand ,
    is this because a trace file with the name XXXX_ora_8218.trc was getting generated with a greater size than the one defined in max_dump_file_size. Is this what happened ?
    Also , I am not able to find what directory does this parameter points to ? is it the trace directory or diag directory ?
    i checked select * from v$diag_info ,but i could not find any conclusion.
    Probably , on getting the above info , i will be able to decide where to move the alert.log to create space.

  • How to write files on Client Machine using JSP

    Hi,
    I am new to JSP. Please tell me how do i write files on Client machine thru a Browser.
    Please let me know at the Earliest.
    Thanks.
    Mehul Dave

    1) Well I find it rather convenient to deploy a web app as just one file rather than a bunch of files. For deployment it's much better. However I prefer using expanded files when developping (to use auto reload in Tomcat for example)
    2) It is a bad idea to upload files inside your webapp's context (ie: in it's deployment directory) because one day an uninformed system administrator might come and redeploy the web app and therefore delete all your uploaded files (believe me, I've already experienced this!)
    What i do usually is upload it in a completely different directory, something like /uploaded_files. Your uploaded files are therefore completely independant from your webapp
    However it is a bit trickyer to get those files back. Let's take the example of image uploads. You have 2 ways of proceeding:
    - the easiest : configure your web server (apache etc...) to redirect a certain url to your external directory. For example the /upload url will point to a /uploaded_files directory. This is easier to do and the fastest way to serve images but not always the best solution: you are dependant on the web server's configuration and you can't control the visibility on your files (no security constraints, anyone can see your uploaded files if they know the url).
    - you can also write a servlet which will load the file as an array of bytes and send it back in the response.
    You can call it this way :
    <img src="/serlvets/showmyimage?path=uploaded.gif">
    in this way you can control your uploaded files better: you may want to define security constraints on the visibity or not of uploaded files depending on the user which has logged on the site.

  • Can I transfer files to a machine from a machine w/a dead screen?

    Question:Can I transfer files to a machine from a machine w/a dead screen?

    If the MBP with the dead screen is otherwise functional, start it up in Target Disk Mode (Powering it up holding the T key/Firewire connecting the two MBPs).  If the other MBP sees the other MBP, you can click on the HDD icon and transfer files.
    Ciao.

  • Why do I get a NI-488 error massage when writing into a file and at the same time copiyng this file with a backup softwarre like Easy2Sync?

    I have a small LabVIEW program which writes random numbers very fast into a ASCII-file. I want that file to be copied to a new position every 10 min. Therefor I use a backup/synchronisation software which is doing a copy operation every 10 min. It works fine a certian amount of time and after a while I get either an LabVIEW error (LabVIEW: Fiel already open: NI-488 Comand requieres GPIB Controller to be System controller) or an backup-software error (couldn´t open file...whatever). I´m guessing, it has something to do with file-access but I don´t know why?!? If I run the LabVIEW program and I copy and paste the random-number-file with the windows explorer very fast (pressing ctrl+v rapidly) while LabVIEW is still writing into this file, no error appears. Can sombody help me?
    LabVIEW 2011

    Hi Serdj,
    you don't get a GPIB error, the error number has just 2 different explanations...
    Well, you have two programs accessing the same file. One program just wants to make a copy, the other (LabView) is trying to write to the file. When copying a file that is written to you get inconsistent results! That's why one of both programs is complaining an error...
    You can't have write and read access at the same time! (But you can have more than one read access at the same time...)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Code for JProgressbar for monitoring  while writing into a files

    Could anybody help me in sample code to implement a JProgressbar while writing into a file.

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.reflect.*; // for InvocationTargetException
    public class Test extends JApplet {
         private JProgressBar pb = new JProgressBar();
         public void init() {
              Container contentPane = getContentPane();
              final JButton startButton = new JButton("start");
              contentPane.setLayout(new FlowLayout());
              contentPane.add(startButton);
              contentPane.add(pb);
              startButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        GetInfoThread t = new GetInfoThread(Test.this);
                        t.start();
                        // this is okay because actionPerformed
                        // is called on the event dispatch thread
                        startButton.setEnabled(false);
         public JProgressBar getProgressBar() {
              return pb;
    class GetInfoThread extends Thread {
         Runnable getValue, setValue;
         int value, currentValue;
         public GetInfoThread(final Test applet) {
              getValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        currentValue = pb.getValue();
              setValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        pb.setValue(value);
         public void run() {
              while(true) {
                   try {
                        Thread.currentThread().sleep(500);
                        // This is okay because the getValue's run()
                        // is invoked on the event dispatch thread
                        value = (int)(Math.random() * 100);
                        try {
                             SwingUtilities.invokeAndWait(getValue);
                        catch(InvocationTargetException ite) {
                             ite.printStackTrace();
                        catch(InterruptedException ie) {
                             ie.printStackTrace();
                        if(currentValue != value) {
                             SwingUtilities.invokeLater(setValue);
                   catch(InterruptedException e) {
                        e.printStackTrace();
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.reflect.*; // for InvocationTargetException
    public class Test extends JApplet {
         private JProgressBar pb = new JProgressBar();
         public void init() {
              Container contentPane = getContentPane();
              final JButton startButton = new JButton("start");
              contentPane.setLayout(new FlowLayout());
              contentPane.add(startButton);
              contentPane.add(pb);
              startButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        GetInfoThread t = new GetInfoThread(Test.this);
                        t.start();
                        // this is okay because actionPerformed
                        // is called on the event dispatch thread
                        startButton.setEnabled(false);
         public JProgressBar getProgressBar() {
              return pb;
    class GetInfoThread extends Thread {
         Runnable getValue, setValue;
         int value, currentValue;
         public GetInfoThread(final Test applet) {
              getValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        currentValue = pb.getValue();
              setValue = new Runnable() {
                   public void run() {
                        JProgressBar pb = applet.getProgressBar();
                        pb.setValue(value);
         public void run() {
              while(true) {
                   try {
                        Thread.currentThread().sleep(500);
                        // This is okay because the getValue's run()
                        // is invoked on the event dispatch thread
                        value = (int)(Math.random() * 100);
                        try {
                             SwingUtilities.invokeAndWait(getValue);
                        catch(InvocationTargetException ite) {
                             ite.printStackTrace();
                        catch(InterruptedException ie) {
                             ie.printStackTrace();
                        if(currentValue != value) {
                             SwingUtilities.invokeLater(setValue);
                   catch(InterruptedException e) {
                        e.printStackTrace();

  • I have to ping a machine from my JSP or Servlet

    I have to ping a machine from my JSP or Servlet what is the best method to do this...

    1) There is a method in java.net.InetAddress called isReachable in JDK 1.5. Because the majority of the Web containers do not support JDK 1.5 nowadays, you can't use it directly in your servlet or JSP. (JBoss 3.2.4 promises to support JDK 1.5 but I couldn't use it with the Beta2.) If you have lots and lots of memory you can try to keep a program running in 1.5 that simply does the "ping" thing, and communicates via sockets with your servlet or JSP.
    2) JNI in Web containers can be used but imposes several problems in class loaders. If you can find a JNI library that can do ICMP ECHO try to use it, but the deployment of the JNI library depends heavily on the Web container.
    3) You can have a program (written in C for instance) that is continuously running and does only the "ping" function, and communicates via sockets with your servlet and JSP. You can have it running now and wait some years until the "isReachable" method is available to your programs.
    4) You could try to Runtime.exec the "ping" command-line executable, but if you are using a Web container you could have some problems (for instance, if you run the Web container as a Windows service the command will not be adequately run, or it runs but never terminates, etc.)

  • Execute a script in a Linux machine from a Java application

    Hi,
    I am trying to execute a script in a Linux machine from a Java application on a Windows environment. My code is
    commande="rsh 185.30.30.30 -l goku /newfolder/bench/bin/Agent start ";
    try{
    Process process = Runtime.getRuntime().exec(commande);
    catch(Throwable t){}
    It works fine but the script takes too much time to start (almost 3 minutes). My question is there exists anther way to execute the script, another command? I have already tried ssh but windows doesn�t recognize it
    If somebody has any idea please let me know...
    Thanks

    The script starts and stops a process (Agent) so it doesn�t take too much time to execute itself. It is when I execute the script from my java program that i must wait to watch my process running in my Linux server.

  • Sending emails from the JSP application

    hi,
    I am trying to send emails from my jsp application using JavaMail API's.
    I am using my own mailserver.
    Iam able to send emails from my applications to the ids of my own mailserver but not the yahoo,gmail and rediff ids.
    Is it because of blocking of any firewall or somthing else to do within my application?
    Can anyone help me in this?
    Thanks a lot.

    Please read the JavaMail FAQ.
    It's probably due to the configuration of your mail server,
    which is refusing to relay your messages.

Maybe you are looking for

  • XML parser causes memory leakage, help!

    I have the following function which called by other package to transfer xml. But every time it is called oracle will consume 600 to 700k memory and never release them. Any thought about it? Function Transform(xml Clob,xsl Clob) Return Clob is p xmlpa

  • Smartform, PDF Error, Unrecognized Token

    Hi all, I have used smarform to send the output of Order Confirmation in PDF format to customer's external mail id. The program is working fine and sending mail to customer's mail id. But the problem is when I am trying to open the PDF file, I am get

  • DISPLAY many pictures

    I want to display many picture (gif, jpg) in a window with their names (all to be shrink to the same size). i also want to be able to select one of the pictures (just one at a time). how can I do it? (p.s- the problem is with the way to display them,

  • Which of these many Input-Streams???

    Hi guys, I want to load the text from an .txt-File into a JTextArea, but I don't know how! If I try it with FileInputStream I ever get an IOException... What can I do??

  • CJ88 automatic settlement

    Hi experts, I need to make automatic settlement in my ABAP program, is there any function module or BAPI that could help me? Thanks in advance. Kind regards, Paul Smuda