File generating question in servlet

Dear all,
I've generated online reports using servlet. Now I need to export these reports to excel at clients' local machine. How to generate the excel file at client's side? or Is that a way to invoke a dialog box to let the user choose the directory to download the file generated at the server side? Somebody says there's an existing funciton in asp to do that. I don't know whether servlet has same function. If anyone knows the answer or could give me a hint, I greatly appreciate that.
Regards,
Grace

Simply change the format of the response content type to be Excel application/vnd.ms-excel... Even if you throw HTML, Excel will parse it and display it as an Excel sheet.
The only disadvantage I have seen is that, you will not be able see Hyperlinks, Images, etc...
Let us say u have a HTML Table like:
<TABLE>
<TR>
<TD>Pazhanikanthan</TD>
<TD>URL</TD>
<TD><IMG SRC='http://www.pazhanikanthan.com/images/test.gif'></IMG></TD>
<TR>
</TABLE>
In the HTML you would have seen a static text, Hyperlink and the Image. But when you try to open the same table in Excel, what happens is Excel does not recognise the HTML Tags and then parses them and only takes up the content which it can display so u will be seeing only a single cell containing the content
Pazhanikanthan
I believe that is a feature which we cannot change... if in case u need to do such things, then you might have to go for special APIs like JExcel, JIntegra, etc.
These wont be suitable for your case as you do not want anything to be done in the server side.
Thanks and regards,
Pazhanikanthan. P

Similar Messages

  • JNLP File Generated By A Servlet

    Based on configuration issues with our system build, I have created a servlet that generates the JNLP file for an app we have created. Once the file is written and contains all the dynamically generated info, it is never written by the servlet again.
    I noticed in creating the servlet, initially, that I actually HAD to write the JNLP file. Returning the JNLP file and setting the mime type in the HTTP response was not enough. When Web Start is invoked by the browser, it goes back to the stored JNLP file on the server.
    Can anyone explain why this is necessary?? Its seems redundant. If I can create the JNLP dynamically and pass it back to the browser, why must Web Start retrieve the JNLP file AGAIN from the web server after it launches??
    John Turner
    Software Engineer
    Context Media, Inc
    [email protected]

    There is a limit to what you can do with dynamically generated JNLP files. The combination of codebase and href must exactly specify the JNLP resource that you are retrieving. If you're using a servlet with parameters in a query string to generate the file, it should look like this:
    <jnlp spec="1.0+" codebase="http://app.datadevelopment.com/app" href="MyServlet?param1=value1&param2=value2">
    As long as the MIME type returned by the servlet is "application/x-java-jnlp-file", JWS will start just fine. Unfortunately, JWS will then bomb badly because it tries to use the href attribute as part of the file name for saving the file, and Windows at least doesn't like question marks in a file name.
    A workaround is to replace the query string with path values:
    <jnlp spec="1.0+" codebase="http://app.datadevelopment.com/app" href="MyServlet/param1=value1/param2=value2">
    I'm not 100% sure that this will work with the '=' sign as my application needed only one parameter so I dispensed with the paramN=valueN and replaced the directory with valueN only. The point is, though, that each and every time the application is launched JWS will go to the web server to get the latest copy of the JNLP and the only way I have found to dynamically generate the content is to append the necessary parameters as path names after the script (JSP in my case, servlet in your case).
    If you have multiple parameters and the '=' sign is a problem, strip out the parameter name and require that the parameters be specified in the same order each time. Use one directory delimiter per parameter.
    You can use request.getPathInfo() to retrieve the path after your servlet.

  • Modifying the name of a file generated by a servlet

    Hi!
    I have a servlet called co.com.SomeStaff who reads a binary file from the server an responses it to the client, but the name that appears when the browser tries to save it is "co.com.SomeStaff" and I need the "SomeBinariFile.exe" instead. How can iI do this?
    I've tried to modify the Headers but....
    I need it as soon as posible.
    Thanks All.

    I assume you are creating the file as a java.io.File object. Under those circumstances you should be able to specify the name and target directory when you save it:File f = new File(directory+System.getProperty("file.separator")+filename);Or, if you have already named it:
    f.renameTo("file.txt");Actually, now I look at it, I may have totally misunderstood what you are trying to do there- are you naming it right in the hyperlink?

  • Question about camera file generator

    Dear all,
    I was trying to set up my camera with the frame grabber using camera file generator. My camera is a linescan camera, which is 1024x1 pixels.
    My question is, in the camera file generator, I can choose to display maximum number of rows which could be any number I key in, for example, I can choose to display 1024x256 or 1024x800.So since my camera has only one line of pixels, where are all the other rows come from?How does it work?
    Thanks a lot!

    Hi
    When you create your icd file, the height value, will be the maximum number of lines you can accumulate.
    So when you will use your camera with MAX or LabVIEW, you can specify an image height within 1 and this value.
    I suggest to set this value pretty high (10000 lines for instance) so that you are free to request a big image in your application.
    Regards

  • Newbie Question - Accessing Servlet Class file

    im trying to run my servlet class file but am not able to do so. I've compiled my servlet and the class file generated is under build...web-inf/classes as it should be. Now how i do access this through the browser , isnt it just not localhost:29080/MyWebApp/HelloServlet. Thanks
    -newbie

    Hi There,
    Are you using Java Studio Creator to develop your application? If so this tutorial will help you get started.
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/jscintro.html
    Please also visit the tutorials page at
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
    Thanks
    K

  • Uploading a file to server using servlet (Without using Jakarta Commons)

    Hi,
    I was trying to upload a file to server using servlet, but i need to do that without the help of anyother API packages like Jakarta Commons Upload. If any class for retrieval is necessary, how can i write my own code to upload from client machine?.
    From
    Velu

    <p>Why put such a restriction on the solution? Whats wrong about using that library?
    The uploading bit is easy - you put a <input type="file"> component on the form, and set it to be method="post" and enctype="multipart/form-data"
    Reading the input stream at the other end - thats harder - which is why they wrote a library for it. </p>
    why i gave the restriction is that, i have a question that <code>'can't we implement the same upload'</code>
    I was with the view that the same can be implemented by our own code right?

  • IMessage interface Comp Controller (JAVA file) generated incompletely

    Hi Experts,
    I am doing a web dynpro java component, it has two views A & B (Comp view)
    I have rebuild the DC but not yet deployed it so no class files yet
    When i checked on the java code of my component controller it implements the IMessage interface, the corresponding package is imported, yet i can not call any values saying "<VALUE> can not be resolved"
    when i checked on the /wdp folder the java file for the IMessage<CompControllerName> does not contain the values, which explains the case above saying value can not be resolved.
    My question is why was this java file generated incompletely (without the values)?
    As i understand this java file is automatically generated by the WD code generator.
    Do i need to define the values manually in the file (by editing it),  or do i specify it graphically?
    Below SHOULD be the complete code generated::
    // This file has been generated by the Web Dynpro Code Generator
    // DON'T MODIFY!!! CHANGES WILL BE LOST WHENEVER THE FILE GETS GENERATED AGAIN
    // $JL-GENERATED-SOURCE$
    package com.ides.soa.cmp.ssc.ui.goodsmovementcomp.wdp;
    * This interface encapsulates all texts / messages for this component.
    * The message constants of type IWDMessage can be used in
    * conjunction with the IWDMessageManager.reportMessage method.
    * All constants can be used in conjunction with IWDTextAccessor.
    @SuppressWarnings("all")
    public interface IMessageGoodsMovementComp {
       * ErrorMessage <code>"Enter a valid {0} to proceed."</code> using
       * key "INVALID_INPUT".
      public static final com.sap.tc.webdynpro.progmodel.api.IWDMessage INVALID__INPUT = new com.sap.tc.webdynpro.progmodel.gci.impl.GCIMessage( com.ides.soa.cmp.ssc.ui.goodsmovementcomp.GoodsMovementComp.class, "INVALID_INPUT", com.sap.tc.webdynpro.services.message.WDMessageType.ERROR );
       * ErrorMessage <code>"Invalid input for goods movement"</code> using
       * key "MISSING_GOODS_INPUT".
      public static final com.sap.tc.webdynpro.progmodel.api.IWDMessage MISSING__GOODS__INPUT = new com.sap.tc.webdynpro.progmodel.gci.impl.GCIMessage( com.ides.soa.cmp.ssc.ui.goodsmovementcomp.GoodsMovementComp.class, "MISSING_GOODS_INPUT", com.sap.tc.webdynpro.services.message.WDMessageType.ERROR );
       * ErrorMessage <code>"The response from the service {0} is null"</code> using
       * key "NULL_RESPONSE".
      public static final com.sap.tc.webdynpro.progmodel.api.IWDMessage NULL__RESPONSE = new com.sap.tc.webdynpro.progmodel.gci.impl.GCIMessage( com.ides.soa.cmp.ssc.ui.goodsmovementcomp.GoodsMovementComp.class, "NULL_RESPONSE", com.sap.tc.webdynpro.services.message.WDMessageType.ERROR );
    I am trying to consume a webservice in wd java
    Thanks in advance

    What you will do in your controller is get a reference to the AM via the pageContext object.
    Like this:
    OAApplicationModule am=(OAApplicationModule)pageContext.getRootApplicationModule();
    Use the am ref to call methods in the am.
    Kristofer Cruz

  • In the header file generated by javah, the package name is not in the funct

    and in the header file generated by javah, the package name is not in the function declaration:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class VocalJNITest */
    #ifndef IncludedVocalJNITest
    #define IncludedVocalJNITest
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: VocalJNITest
    * Method: JNI_1myJNI
    * Signature: ()V
    JNIEXPORT void JNICALL Java_VocalJNITest_JNI_11myJNI (***please not there is no package name in it****)
    (JNIEnv *, jclass);
    #ifdef __cplusplus
    #endif
    #endif
    In the VocalJNITest.java file, I put package com.jni.test in it, why dose it not appear in the VocalJNITest.h file.

    it works,
    thanks alot, but java really confuses me, for example, if i run the app, i need to type the complete name java com/...../jnitest, in which the "/" is used instead of
    ". " like com.vocal.jnitest as the package name in the source file.
    but when using javah, i need to use ". " instead of "/";
    i tried com/vocal/jnitest, but failed so i post the question here.

  • Character set conversion UTF-8 -- ISO-8859-1 generates question mark (?)

    I'm trying to convert an XML-file in UTF-8 format to another file with character set ISO-8859-1.
    My problem is that the ISO-8859-1 file generates a question mark (?) and puts it as a prefix in the file.
    ?<?xml version="1.0" encoding="UTF-8"?>
    <ns0:messagetype xmlns:ns0="urn:olof">
    <underkat>testv���rde</underkat>
    </ns0:messagetype>
    Is there a way to do the conversion without getting the question mark?
    My code looks as follows:
    public class ConvertEncoding {
         public static void main(String[] args) {
              String from = "UTF-8", to = "ISO-8859-1";
              String infile = "C:\\temp\\infile.xml", outfile = "C:\\temp\\outfile.xml";
              try {
                   convert(infile, outfile, from, to);
              } catch (Exception e) {
                   System.out.println(e.getMessage());
                   System.exit(1);
         private static void convert(String infile, String outfile,
                                            String from, String to)
                             throws IOException, UnsupportedEncodingException
              //Set up byte streams
              InputStream in = null;
              OutputStream out = null;
              if(infile != null) {
                   in = new FileInputStream(infile);
              if(outfile != null) {
                   out = new FileOutputStream(outfile);
              //Set up character streams
              Reader r = new BufferedReader(new InputStreamReader(in, from));
              Writer w = new BufferedWriter(new OutputStreamWriter(out, to));
              /*Copy characters from input to output.
               * The InputSreamreader converts
               * from Unicode to the output encoding.
               * Characters that cannot be represented in
               * the output encoding are output as '?'
              char[] buffer = new char[4096];
              int len;
              while((len = r.read(buffer))!= -1) { //Read a block of output
                   w.write(buffer, 0, len);
              r.close();
              w.flush();
              w.close();
    }

    Yes the next character is the '<'
    The file that I read from is generated by an integration platform. I send a plain file to it (supposedly in UTF-8 encoding) and it returns another file (in between I call my java class that converts the characterset from UTF-8 to ISO-8859-1). The file that I get back contains the '���' if the conversion doesn't work and '?' if the conversion worked.
    My solution so far is to skip the first "junk-characters" when reading from the inputstream. Something like:
    private static final char UTF_BOM = '\uFEFF'; //UTF-BOM = ?
    String from = "UTF-8", to = "ISO-8859-1";
    if (from != null && from.toLowerCase().startsWith("utf-")) { //Are we reading an UTF encoded file?
    /*Read first character of the UTF-Encoded file
    It will return '?' in the first position if we are dealing with UTF encoding If ? is returned we skip this character in the read
    try {
    r.mark(1); //Only allow to read one char for the reset function to work
    char c;
    int i = r.read();
    c = (char) i;
    if (String.valueOf(UTF_BOM).equalsIgnoreCase(String.valueOf(c))) {
    r.reset(); //reset to start position
    r.skip(1); //Skip first character when reading from the stream
    else {
    r.reset();
    } catch (IOException e) {
    e.getMessage();
    //return null;
    }

  • UTF-8 csv file generated by Java can't be displayed correctly on Excel 2000

    Hi, I have a question about the file geneated by Java in UTF-8 format. If I have a file named "foo.csv" generated by my java code like this:
    writer = new OutputStreamWriter(new FileOutputStream("foo.csv"), "UTF-8");
    Then I write some data loaded from a MS SQL 2000 server to this file. Some data are in German or french characters. After the file is generated, if I open it in notepad, all the characters in the file looks good. The file is in UTF-8 format. The only problem is that when I open this csv file in MS Excel 2000, all the non-english character display incorrectly. For example:
    "VERKTYGSTEKNIK I V�XJ� AB" display as itself in notepad, but it display as "VERKTYGSTEKNIK I V��XJ�� AB" in the MS Excel. I don't know the reason. If I don't have the encoding in the writer, then the file generated looks fine in the Excel (Even the non-English characters), in this case, the file is generated in ANSI format. But my client wants the file in UTF-8 format and also want to view it in Excel.
    Why the UTF-8 file generated by Java can't be displayed correctly in Excel 2000?
    My environment is:
    OS: Window 2000 Server English Version
    JDK: Sun jdk1.3.1
    Thanks

    - Does ms excell actually support UTF-8
    Yes. I believed that we installed some international add-on which is not in default installnation. Anyway, other UTF-8 or UTF-16 file can be openned and viewed by Excel without any problem.
    - have you verifide that the file is viewable as a UTF-8 -encoded file
    I think so. If I open it into Notepad and choose "save as", the file type if UTF-8 file
    - Try opening the file in a program you are confident
    that it support UTF-8 - eg. Mozilla...
    I will try that.
    - Check that your UTF-8 -encoded file has a UTF-8 identifier (0xFEFF ?)
    as the first character
    The unicode-16(LE or BE) file I got from internet, I found there is always two bytes in the front. (0xFEFF or 0xFFFE). My UTF-8 file generated by java doesn't have that. But should UTF-8 file also has this kind of specifcal bytes in the front? If I manually add these bytes in the front of my file using Ultraeditor and open it in Excel2000, it didn't help.
    - Try using another spreadsheet program that supports UTF-8
    Do you know any other spreadsheet program supports csv file and UTF-8.

  • Camera File Generator Won't Run with MAX + PCIe-1433

    Hi,
    I am a camera developer and am trying to integrate a couple of new cameralink cameras with the PCIe-1433 NI frame grabber.  I have installed NI MAX 14.0 and version 3.0.0 of the Camera File Generator.
    I am trying to build a new Camera File for our companies cameras.
    The NI MAX shows the NI PCIe-1433 device when it launches.
    When I try to launch the Camera File Generator, it failis to load with the following message:
    "You must have NI-IMAQ 4.6.0 or higher installed before running the NI Camera File Generator.  NI-IMAQ 4.6.0 is installed with Vision Acquisition Software 2011."
    The MAX configuration tree shows I have version 14.0 of the NI-IMAQ software available.
    Is there any sort of developer's guide for creating a camera file to allow me to use my camera?  I need to write some serial commands to the unit and thought tha tthe Camera File Generator would support this.... 
    Thanks.
    -Mike

    Hi mawillia,
    The latest version of the IMAQ drivers is version 4.9, and it would show up where you said, under the Software tab in NI MAX.  Do you have this latest version installed?  If you like, feel free to expand out your software tab and take a picture of it and post it here.
    Also, you are correct that the serial commands can be set in the camera file.  Here is a link to our support page for the Camera File Generator: http://sine.ni.com/psp/app/doc/p/id/psp-723/lang/en
    Within it is a whole host of various KnowledgeBase articles.  This one seems particularly helpful:
    What framegrabber specifications do I need to know to create my camera file?:  http://digital.ni.com/public.nsf/allkb/9B89C9FA43A6973A86257A62004658D5
    Unfortunately, I couldn't find any articles specific to coding the serial commands for your camera in the camera file.  But I recommend opening up one of the bundled camera files (I'm looking at the Basler acA2000-340kc (Base).icd ) and within that, click the Camera Control tab.  The serial commands for each attribute will show up on the right side, and you can use this as an example for creating yours.
    Let me know if you have any further questions!
    Julian R.
    Applications Engineer
    National Instruments

  • Digital waveform editor can not open hws file generated by niHWS store waveform

    Hi,
    I am using a simple VI to store the U32 array to a hws file in LabVIEW, however, the file generated can not be opened by Digital Waveform Editor. The VI used to be working well before I upgrade LabVIEW from V7 to V7.1.
    Meanwhile I also found out that the hws file generated by DWE can not be read out by niHWS. retrieve waveform.vi if the number of channels is not 32.
    I would be grateful if any one can give me some help. Please find the VIs and hws files as attached.
    The software I am using is
    Digital Waveform Editor 1.0
    LabVIEW 7.1
    Best Regards, YJ2003
    Attachments:
    question Get ArrayU32 from HWS Data.vi ‏108 KB

    Dear Brian,
    Thanks for your quick response.
    I tried again but still failed to open the hws file with my DWE V1.0. Since the version is the only difference between our software, I suspect the problem is caused by my DWE of old version.
    Would you please help me to check if the new attached questionretrievepattern.hws file can be opened by the HWS.VI? (Please change the extention from txt to hws as I can not attach file with hws format in this forum)This file is generated by DWE1.0 and contain only 16 channels. It can not be opened by the niHWS retrieve waveform.vi in my computer with erroe code "-21558", but if I added another 16 channels signals with DWE, the data can be read out properly.
    If we can confirm the problem is caused by DWE1.0, would you please also let me know how to upgrade my DWE? Thanks.
    Best Regards, YJ2003
    Attachments:
    questionretrievepattern.txt ‏35 KB

  • I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    I got new hard driver for my MacBook I don't have the cd but I do have flash drive that has the software I need help because when I turn on my laptop it shows me a file with question mark how can I install the software from the flash driver?

    Hold down the Option key while you boot your Mac. Then, it should show you a selection of devices. Click your flash drive and it will boot from that.

  • Change file name with oreilly servlet

    I am using oreilly servlet package and I want to change the file name to the file I am uploading, is this possible ?
    How ?
    Thanks.
    here I post the servlet code:
    package com.reducativa.sitio.servlets;
    * DemoParserUploadServlet.java
    * Example servlet to handle file uploads using MultipartParser for
    * decoding the incoming multipart/form-data stream
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import com.oreilly.servlet.multipart.*;
    public class DemoParserUploadServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    response.setContentType("text/plain");
    out.println("Demo Parser Upload Servlet");
    File dir = new File("f:/");
    if (! dir.isDirectory()) {
    throw new ServletException("Supplied uploadDir " + "f:/ " +
    " is invalid");
    try {
    MultipartParser mp = new MultipartParser(request, 10*1024*1024); // 10MB
    Part part;
    while ((part = mp.readNextPart()) != null) {
    String name = part.getName();
    if (part.isParam()) {
    // it's a parameter part
    ParamPart paramPart = (ParamPart) part;
    String value = paramPart.getStringValue();
    out.println("param; name=" + name + ", value=" + value);
    else if (part.isFile()) {
    // it's a file part
    FilePart filePart = (FilePart) part;
    String fileName = filePart.getFileName();
    if (fileName != null) {
    // the part actually contained a file
    long size = filePart.writeTo(dir);
    out.println("file; name=" + name + "; filename=" + fileName +
    ", filePath=" + filePart.getFilePath() +
    ", content type=" + filePart.getContentType() +
    ", size=" + size);
    else {
    // the field did not contain a file
    out.println("file; name=" + name + "; EMPTY");
    out.flush();
    catch (IOException lEx) {
    this.getServletContext().log("error reading or saving file");
    }

    Hi there,
    I am facing the same problem that you have stated in your Feb 26, 2002 10:28 AM message regarding "change file name with oreilly servlet", I would like to change the file name to include a unique identifier upon upload, did you ever find a solution to your problem?
    Thanks!
    Todd
    [email protected]

  • Field Value not passed from IDOC (orders01) to File Generated

    Hi All,
    I have added a custom field to a PO at item level (ekpo-Ztest)and Passing it to OUTBOUND IDOC.
    In process of passing to IDOC(ORDERS01) i mapped the field to segment E2EDP19001-MFRPN and i see the value in the IDOC when i view it in WE02.
    The problem is when i generate a file i don't see the value of E2EDP19001-MFRPN
    We are already using QUALF,IDTNR,KTEXT of E2EDP19001 and i see all the values of these fields being passed from IDOC to file generated .
    Let me know as i'm missing anything in here
    I quick note ,
    I see 3 version for E2EDP19 Segment for orders01
    Vesrion
    002     E2EDP19002                             8     242     02/14/2005
    001     E2EDP19001     40A                    5     160     08/19/1997
    000     E2EDP19             30A                     3     108     04/03/1995
    1)The version 000 and 001 are released but not 002 Version
    2)May be i 'm using version 000 and its out put length is only 108 and these fields(QUALF,IDTNR,KTEXT) together occupy 108 and there is no room for my new field but My IDOC dispalys E2EDP19001 and E2EDP19002 and also it displays my new field but its the output file generated that doesn't show the value
    Thanks

    Resolved Myself
    Thanks

Maybe you are looking for

  • Error when opening Data Form

    Hi All, Also I have tried by removing access for that user and opened the Dta Form but still it throwing me the same error: You are trying to open the data form, but cannot because all of the required dimensions are not present. Possible causes may b

  • Screen not working, Compaq Presario CQ62-215DX

    Hello, My Notebook screen is not working. My notebook boot up fine. the lights and the fan is working.  When I plug the external VGA to my lcd screen, it works fine. Only the notbook monitor is not working. which part in this case that needs to be ch

  • Customer line item display prints every account on a seperate page

    Hello When I print FBL5N for all the customers or group of customer, on the screen it looks good, but when I send it to the printer, the report is printed with a new page for each customer. Is there any option to cancel this page break for every acco

  • Saving query view in a internal table

    Hello Experts, Is there anyway that we can trasfer all the query results to a table. What I am exactly looking is I want to transfer a query view to an internal table so that our destop team using java will then read the results from tables and conve

  • In ODI, SunopsisMQ doesn't exist anymore?

    I remember Sunopsis had its own MQ before. So I had to install SunopsisMQ separately... But now I can't find Sunopsis MQ installation file or manual documents. Does this function disappeared in ODI? Thanks in advance. ji-young