Unable to save the data in a .CSV format

Hi All,
I am trying to pull some data with the help of the sql query from the database and then trying to save this string of data in csv file by using the following code as shown below.The problem iam facing here is that while the file Save as window opens stating to be saved as .CSV format but when i try to save it ,it doesnt givme a csv option ,only html option appears.Can any one help me on this..,,,,,,,,,,,,?
<%@include file="jtfincl.jsp" %>
<%@page session="false" %>
<%@page import="java.io.PrintWriter"%>
<%@page import="oracle.apps.ibe.util.RequestCtx"%>
<%@page import="oracle.apps.iri.iribe.postsales.IrIbeOrderSearch"%>
<%@page import="oracle.apps.ibe.util.*" %>
<%@page import="java.io.IOException" %>
<%
pageContext.setAttribute("_securePage", "true", PageContext.REQUEST_SCOPE);
pageContext.setAttribute("_guestNotAllowed", "true", PageContext.REQUEST_SCOPE);
pageContext.setAttribute("_unapprovedNotAllowed", "true", PageContext.REQUEST_SCOPE);
RequestCtx rCtx = RequestCtx.start(request, response);
int status = Session.checkContextValues(request, response);
if(RequestCtx.userIsAnonymous()) {
signin(out, pageContext, request, response, false);
return;
// Set the response type which in this case will be a .csv file
response.setContentType("application/csv");
response.setHeader("Content-disposition","attachment;filename=SearchResults.csv");
String queryStartDate = request.getParameter("queryStartDate");
String queryEndDate = request.getParameter("queryEndDate");
String queryField = request.getParameter("queryField");
String queryOperator = request.getParameter("queryOperator");
String queryValue = request.getParameter("queryValue");
String queryOrderByField = request.getParameter("queryOrderByField");
String showOpenOrdersOnly = request.getParameter("showOpenOrdersOnly");
IrIbeOrderSearch orderSearch = new IrIbeOrderSearch(
queryStartDate,
queryEndDate,
queryField,
queryOperator,
queryValue,
queryOrderByField,
showOpenOrdersOnly
orderSearch.initialise();
java.util.ArrayList results = orderSearch.getItemTrackerSearchResults();
     out.println("The result array size is======="+results.size()) ;
// Output the results as the page resonse as a csv file
     try
write(results, response.getWriter());
     catch(exception e)
     out.println("The stack trace is======="+e.printStackTrace()) ;
     if(IBE_logEnabled) IBEUtil.log("iribeCOtdOrdSearchExport.jsp","Inside the exception"+e.toString);
%>
<%!
* This method will take a ResultSet and JspWriter object and print out the details of the ResultSet as a
* comma seperated value file.
* @param results
* @param writer
public static void write(java.util.ArrayList results, PrintWriter writer) {
if(results == null || results.size() == 0) {
writer.print("No Data Available");
return;
String [] data = null;
String output = "";
          if(IBE_logEnabled) IBEUtil.log("iribeCOtdOrdSearchExport.jsp","Inside the write method");
for(int i = 0; i < results.size(); i++) {
data = (String []) results.get(i);
output = "";
for(int j = 0; j < data.length; j++) {
// If its not the last column
if(j != data.length - 1) {
output += formatField(data[j]) + ",";
// If it is the last column
} else {
output += formatField(data[j]);
writer.println(output);
writer.flush();
* Format a string value so that it becomes a valid field in a .csv file. This involves making sure that any null
* data is treated as an empty string, that any quotes are padded and if the file contains any commas that the
* field is surrounded by quotes.
* @param value
private static String formatField(String value) {
String output = null;
// Check for null values
if(value == null) {
output = "";
} else {
output = value;
// Pad any existing quotes
output = output.replaceAll("\"", "\"\"");
// If there is a space or commas then add surrounding quotes
if(output.startsWith(" ") || output.endsWith(" ") || output.indexOf(",") != -1) {
output = "\"" + output + "\"";
return output;
%>
<%!
void signin(
JspWriter out,
PageContext pageContext,
HttpServletRequest request,
HttpServletResponse response,
boolean reauth
) throws IOException, SQLException, FrameworkException {
String query = IBEUtil.passQueryString(request, null).toString();
String uri = request.getRequestURI();
String targetJsp = uri.substring(uri.lastIndexOf("/") + 1);
String ref = null;
if ("true".equals(pageContext.getAttribute("_securePage", PageContext.REQUEST_SCOPE))) {
ref = RequestCtx.getSecureFormAction(targetJsp);
} else {
ref = RequestCtx.getNonSecureFormAction(targetJsp);
if(!query.equals("")) {
ref = oracle.apps.jtf.util.Utils.encode(ref + "?" + query);
String redirect = RequestCtx.getSecureURL("ibeCAcpSSOLogin.jsp", "ref=" + ref + (reauth ? "&reauth=t" : ""));
// don't add the ref if the session expired and restarted
RequestCtx rCtx = RequestCtx.getRequestCtx();
if(rCtx.startRequestException!=null) {
redirect = RequestCtx.getSecureURL("ibeCAcpSSOLogin.jsp", "ibe_se=t"+(reauth ? "&reauth=t" : ""));
RequestCtx.end(request);
response.sendRedirect(redirect);
regds
manish
%>

This would occur if you were using IE and the requested URL doesn't contain the filename part. The real web browsers would pick up the filename from the response header flawlessly.
Having said that, this kind of logic doesn't belong in a JSP. Use Java classes (Servlet, Bean, DAO). Further on, JSP/Servlet related questions should be posted in the JSP/Servlet forum.

Similar Messages

  • Unable to Save the Data Using BexSetData

    Hi All,
    I have a issue regarding saving plan data,
    Design: I  got a Workbook with several tabs, each tab has a input ready Query and has a layout as below
    A formatted user facing worksheet containing; an area where the user enters their plan data with a BEx save data button, an input ready query and a worksheet containing the BExSetData formulas that reference the values entered on the user facing worksheet.
    Issue: When i try to enter the value in the user facing sheet, the data is shown in the BexSet Data Sheet with out any problem,
    But when i try to save the data the data is not saved into the cube.
    Can any one please give some ideas of possible cause.
    One more question is the input ready query doesn't have any references to other sheets, will this be a reason for the data not saved?
    Please through some ideas.
    Thanks
    GC

    Hello,
    I think it is problem with the buffer:
    Check the notes 1136163, 1138864, 1146957, 1179076.
    please check the below;
    Delta buffer query in RSRT for BI-IP ("<infoprovider>/!!1<infoprovider>)
    Planning query donu2019t show the current data
    Thanks.
    With regards,
    Anand Kumar

  • Unable to save the ALV layout variant and display of selection screen on F4

    Hi All,
    The end user wants to directly select the layout variant (SLIS_VARI). I have used the following code to display the layout variant on selection screen. But, I am unable to save the variant on ALV. Whenever I am trying to select the layout variants (by doing F4 on selection screen) its displaying "No Layout found".
    Following is the code for displaying layout variant:
    PARAMETERS: p_var TYPE slis_vari.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
      PERFORM f4_variant CHANGING p_var.
    FORM f4_variant  CHANGING c_variant TYPE slis_vari.
      DATA: ls_variant TYPE disvariant,
                l_exit     TYPE char1.
      ls_variant-report = sy-repid.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = ls_variant
          i_save     = 'A'
        IMPORTING
          e_exit     = l_exit
          es_variant = ls_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        IF l_exit EQ space.
          c_variant = ls_variant-variant.
        ENDIF.
      ENDIF.
    ENDFORM.                    " f4_variant
    and following is the code for displaying the ALV:
    FORM edition_alv.
      ws_variant2 = ls_variant.
    * Call ALV editor in list mode
      IF p_list = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            i_callback_program      = ws_extract1-report
            i_callback_user_command = ws_user_command
            is_layout               = ws_layout
            it_fieldcat             = wt_fieldcat
            it_sort                 = wt_sort
            i_save                  = 'A'
            is_variant              = ws_variant2
            it_events               = wt_events[]
          TABLES
            t_outtab                = wt_edition.
    * Call ALV editor in grid mode
      ELSE.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program      = ws_extract1-report
            i_callback_user_command = ws_user_command
            it_fieldcat             = wt_fieldcat
            it_sort                 = wt_sort
            i_save                  = 'A'
            is_variant              = ws_variant2
            it_events               = wt_events[]
          TABLES
            t_outtab                = wt_edition.
      ENDIF.
    ENDFORM.  
    I am not sure whats going wrong, but I am unable to save variants.
    Please help.
    Thanks,
    Vishal.

    The F4 will display you the existing layouts only. So you need to save the layout first & then execute the report again & check if you are getting F4 values for that field.
    The Layout needs to get stored with variant.
    Regards,
    Mahesh

  • Getting an error in Timesheet as "Unable to save your data"

    Hi
    When i am entering the data in timesheet for a WBS element-Annual leave,on confirmation page getting an error as "Unable to save your data"
    Can anyone help me on this issue
    Thanks

    Hi,
    check here:
    Errors in ESS Timesheet and Leave Request
    Also, if this doesn't help you, please post the error's detailed default trace log of NWA Monitoring here. Maybe you also got something in ST22 in Backend
    best regard, Lukas

  • A string that can be displayed as both ASCII and hex in an indicator will only save the data to a file in ASCII format

    We can see the data in an indicator just fine, but when we try to write that string of hexadecimal data to a file, it will only save the data in ASCII format.  
    This sounds fairly simple, as the indicator can be selected to display the data in several different formats (VI>Properties>Appearance>Display Style: Normal, Backslash...., Hexadecimal).  However, I have been unable, as of yet, to save the data in different formats.
    Solved!
    Go to Solution.

    altenbach wrote:
    ... or you could just read the string:text.text property to get whatever is actually displayed.
    like this...
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    texttextString.PNG ‏6 KB

  • How do I save IRS pdf forms so that I can fill in and save the data

    when I downlaod a US government IRS form I am unable to fill in the form, save the data and print, I have tried saving as a pdf from the print menu and using the tools menu none of which works

    I know there is an app called PDFPen that is supposed to fill in PDF forms.  PDFPen is available in the App Store, but it is not free.
    I have no financial interest in PDFPen.  I also don't know if there is some cheaper way to fill in the forms.

  • Unable to set the date & time screensaver in nokia...

    I enabled the settings in the phone. Once the keypad is locked, the backlight goes off and unable to see the date & time screensaver. The screen saver is visible only after i press any key.

    This is normal behavior most of nokias phone will go black after a period of time to save battery...
    If  i have helped at all a click on the white star below would be nice thanks.
    Now using the Lumia 1520

  • Unable to change the data in PSA

    Hello All,
    I have a delta failure because of invalid characters in one of the field and now i wanted to change the PSA. I have deleted the request from all data targets and started changing the error record, it is not showing all columns from PSA hence i am unable to change the data in required field.
    Could you please let me know how will i see all columns from PSA. Thanks
    Regards,Ashok

    Hi Ashok,
    To increase/decrease the number of columns that are displayed on the menu from the Settings option select Change display variants
    Also if you want to see say all the failed records you can sort the order of the data using the Status column

  • Unable to access the data from Data Management Gateway: Query timeout expired

    Hi,
    Since 2-3 days the data refresh is failing on our PowerBI site. I checked below:
    1. The gateway is in running status.
    2. Data source is also in ready status and test connection worked fine too.
    3. Below is the error in System Health -
    Failed to refresh the data source. An internal service error has occurred. Retry the operation at a later time. If the problem persists, contact Microsoft support for further assistance.        
    Error code: 4025
    4. Below is the error in Event Viewer.
    Unable to access the data from Data Management Gateway: Query timeout expired. Please check 1) whether the data source is available 2) whether the gateway on-premises service is running using Windows Event Logs.
    5. This is the correlational id for latest refresh failure
    is
    f9030dd8-af4c-4225-8674-50ce85a770d0
    6.
    Refresh History error is –
    Errors in the high-level relational engine. The following exception occurred while the managed IDataReader interface was being used: The operation has timed out. Errors in the high-level relational engine. The following exception occurred while the
    managed IDataReader interface was being used: Query timeout expired. 
    Any idea what could have went wrong suddenly, everything was working fine from last 1 month.
    Thanks,
    Richa

    Never mind, figured out there was a lock on SQL table which caused all the problems. Once I released the lock it PowerPivot refresh started working fine.
    Thanks.

  • Unable to send the data entered in sap portal

    Hi
    All
    i am trying to configure and test  Leave Request  from portal. When, we create the leave request and submit for the first time, it is giving the error/message Unable to send the data entered However, if do a submit for the second time, the same leave request, it sends the leave request.
    Please share your valuable thoughts or solutions.Thanks in advance.
    Tanks
    Rafi Shaik

    Hi Rafi,
    We are also facing similar kind of issue.
    When i select type of leave as annual it is giving an error message as
    " Parameter  missing in call of method BUILD_ACTOR_SELECT_CLAUSE in class CA_PT_REQ_ACTOR "
    But when i select some other leave type and click review it is working fine, again if i click on previous step and change the leave type to annual it is working fine without giving any error message.
    Please let us know how you have solved your issue?
    Thanks.
    -Suresh

  • The ADO NET Source was unable to process the data. ORA-64203: Destination buffer too small to hold CLOB data after character set conversion.

     We developed a SSIS Package to pull the data From Oracle source to Sql Server 2012. Here we used ADO.Net source to pull the records from Source but getting the below error after pulling some 40K records.
      [ADO NET Source [2]] Error: The ADO NET Source was unable to process the data. ORA-64203: Destination buffer too small to hold CLOB data after character set conversion.
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. 
     The PrimeOutput method on ADO NET Source returned error code 0xC02090F5. 
     The component returned a failure code when the pipeline engine called PrimeOutput(). 
    The meaning of the failure code is defined by the component, 
    but the error is fatal and the pipeline stopped executing. 
     There may be error messages posted before this with more 
    information about the failure.
    Anything that we can do to fix this?

    Hi,
      Tried both....
      * Having schema type as Nvarchar(max). - Getting the same error.
      * Instead of ADO.Net Source used OLEDB Source with driver as " Oracle Provide for OLE DB" Getting error as below.
           [OLE DB Source [478]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
           [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on OLE DB Source returned error code 0xC0202009.  The component returned a failure
    code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the
    failure.
    Additional Info:
       * Here the Source task is getting failed not the conversion or destination task.
    Thanks,
    Loganathan A.

  • Unable to get the data when capture the BOL object infomation.

    Hello All.
    I created a Z component.
    In that component I created one View.
    In that view i have the context node with BOL object  -  BTAdminH
    In configuration also i am selecting the fields.
    But I am unable to capture the data.
    In that i write like
    data: lr_ent type ref to CL_CRM_BOL_ENTITY.
    lr_ent ?= me->typed_context->btadminh->collection_wrapper->get_current( ).
    I write this code in the EDIT button event.
    But lr_ent is not capture any value.
    BTADMINH is there in the CTXT class.
    In debugging GET_CURRENT( ) method
    me->collection_ref->collection
    is not having any value.
    I do not know why it is not having any value.
    When I am using value node it is working fine.
    But when i am using BOL object at that time only it is not getting any value.
    Can anybody give me suggision to solve this problem.
    In stadard it is working fine.
    How it is working in Stadard i did not understand.
    Why it is not working in Z component.
    How we can use BOL objets in Z components.
    Please give me some solution.
    Regards,
    B. Krishna.

    Hi krishna
    Is this a Z component to be used within a  standard component?
    ->then you need to create a usage definition to this component from standard
    ->expose btadminh as public context through component controller
    ->create binding to the standard btadminh through the usage initialize method
    then it should be okay
    If the Z component is standalone , then create Root object BTorder and BTAdminH node should having a hierarchial relationship to this. Initialize BTOrder through cl_crm_bol_core methods.

  • Unable to load the data into Cube Using DTP in the quality system

    Hi,
    I am unable to load the data from PSA to Cube using DTP in the quality system for the first time
    I am getting the error like" Data package processing terminated" and "Source TRCS 2LIS_17_NOTIF is not allowed".
    Please suggest .
    Thanks,
    Satyaprasad

    Hi,
    Some Infoobjects are missing while collecting the transport.
    I collected those objects and transported ,now its working fine.
    Many Thanks to all
    Regards,
    Satyaprasad

  • BOFC Unable to start the data source

    Hi there,
    i've done a standalone install using SQL 2008 R2 express. But i'm unable to start the data source and get this error:
    Failed to start data source
    Failed to start server instances on machine DELL1.
    Failed to initialize server configured on machine DELL1.
    Class not registered
    Thanks,
    Anees

    Ok, problem solved.
    I had to create a seperate DCOM user and assign it to the following roles in windows:
    log on as a batch job
    log on as a service
    then assign this DCOM user to the Ctbroker and CTserver. As i'm not running this on a domain, there was no need to use 'packet level authentication'. So i set the authentication level to none.
    There was no need to use the web based admin interface. Ctadmin.msc worked perfectly.
    Thanks,
    Anees

  • Unable to change the data source of SAP system

    Dear all,
    We have install SAP netweaver EHP1 standalone java on oracle 10.2.0.5 on windows 2008 R2.
    while installation i have given the central SLD system as solman,
    By mistake i have deleted the system from SMSY.. now when i createed the system manually i am unable to change the data resource as SLD due to this i can start my SMD configuration
    Request please let me know how to resolve this issue.
    Thanks
    Paresh

    Hi Paresh,
    You can proceed with deleting your SAP system from SMSY (along with connected technical content such as AS Java definition) and the run the LANDSCAPE FETCH through transaction SMSY_SETUP to have the correct definition of your SAP system in SMSY.
    Following this, you could use the addon Landscape Verification (a new thing I learnt today!!!)  to check the correctness of transaction SMSY. The following link details the Landscape verification 1.0 for SolMan:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e093b3ce-c034-2d10-01bc-b51f1691d3da?quicklink=index&overridelayout=true
    Hope this helps sort out your issue.

Maybe you are looking for

  • SELECT TOP 1 .... ORDER BY

    Hi, I have the following statement in SQL SERVER: SELECT TOP 1 NAME FROM STUDENT ORDER BYGRADE Now, I am trying to translate it ti ORACLE PLSQL, I came up with this statement: SELECT NAME FROM STUDENT WHERE ROWNUM=1 ORDER BY GRADE It doesn't work. I

  • Workflow Setup and possibilities

    Dear Gurus, I have a client who wants to be able to do multi authoriser through a single initiator while all workflows are active. I currently drive this using below scenario; Mr. A, B, C are authorisers while Mr Y is the initiator of all documents.

  • NSU reports incorrect FW version

    Hi, I'm trying to update my N95, when I check for firmware NSU tells me I have version "6wk41v59.1" and no updates are available... *#0000# says i'm on version 30.0.0.015 15-07-18. I've reinstalled everything several times, a quick google indicates o

  • Fireworks CS6 Internal Error, other components APPCRASH

    Hello, I have tried installing this CS6 Web Premium for the past month on my corporate machine. My local IT has re-imaged and even replaced my hard drive a number of times with fresh CS6 installs right after. 32 & 64 bit. Currently I am on a new hard

  • WIndows 7 64bit, how much ram I need to get Photosgop CS5 flying?

    Hi guy,s I have just transfered over from a 32bit Vista to WIndows 7 64-bit on a dual core 3Ghz, 4Gb RAM. Just wondering how much extra RAM should I get to get the most/best out of photoshop I am really hoping my files files a bit quicker. allround.