Flush a string to the browser as a file?

How can I flush a string to the browser and make the browser save it like a file?
This is what I've got so far:
String info = "somthing funny here";
response.setContentType("text/plain");
response.setHeader("Content-Disposition", "filename=message.txt");
ServletOutputStream os = response.getOutputStream();
InputStream is = <somehow get t String info input stream?? >
int j = 0;
while ((j = is.read()) != -1) {
    os.write(j);
os.flush();
os.close();Thanks!

Try changing this:
response.setHeader("Content-Disposition", "filename=message.txt");to this:
response.setHeader("Content-Disposition", "attachment; filename=message.txt");

Similar Messages

  • XML Report completes with error due to REP-271504897:  Unable to retrieve a string from the Report Builder message file.

    We are in the middle of testing our R12 Upgrade.  I am getting this error from the invoice XML-based report that we are using in R12. (based on log).  Only for a specific invoice number that this error is appearing.  The trace is not showing me anything.  I don't know how to proceed on how to debug where the error is coming from and how to fix this.  I found a patch 8339196 that shows exactly the same error number but however, I have to reproduce the error in another test instance before we apply the patch.  I created exactly the same order and interface to AR and it doesnt generate an error.  I even copied the order and interface to AR and it doesn't complete with error.  It is only for this particular invoice that is having an issue and I need to get the root cause as to why.  Please help.  I appreciate what you all can contribute to identify and fix our issue.  We have not faced this issue in R11i that we are maintaining right now for the same program which has been running for sometime.  However, after the upgrade for this particular data that the user has created, it is throwing this error REP-271504897.
    MSG-00100: DEBUG:  Get_Country_Description Return value:
    MSG-00100: DEBUG:  Get_Country_Description Return value:
    REP-0002: Unable to retrieve a string from the Report Builder message file.
    REP-271504897:
    REP-0069: Internal error
    REP-57054: In-process job terminated:Terminated with error:
    REP-271504897: MSG-00100: DEBUG:  BeforeReport_Trigger +
    MSG-00100: DEBUG:  AfterParam_Procs.Populate_Printing_Option
    MSG-00100: DEBUG:  AfterParam_Procs.Populate_Tax_Printing_Option
    MSG-00100: DEBUG:  BeforeReport_Trigger.Get_Message_Details
    MSG-00100: DEBUG:  BeforeReport_Trigger.Get_Org_Profile.
    MSG-00100: DEBUG:  Organization Id:  117
    MSG-00100: DEBUG:  BeforeReport_Trigger.Build_Where_Clause
    MSG-00100: DEBUG:  P_Choi
    Report Builder: Release 10.1.2.3.0 - Production on Tue Jul 23 09:56:46 2013
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.

    Hi,
    Check on this note also : Purchasing Reports Fail When Changing Output To XML REP-0002 REP-271504897 REP-57054 (Doc ID 1452608.1)
    If you cant reproduce the issue on other instance, apply the patch on the test instance and verify all the funcionality related to the patch works OK. Then move the patch to production. Or you can clone the prod environment to test the patch.
    Regards,

  • REP-0002: Unable to retrieve a string from the Report Builder message file;

    Hi,
    I've a custom report in which i need to display a large string, of more than 4000 characters. To cater to this requirement i've written a formula column which displays string upto 4k characters and for a string of size beyond 4k i am calling a procedure which uses a temp table having a clob field.
    For a small string the report runs fine but whenever a large string requirement comes into the picture, said procedure gets triggered and i get REP-0002: Unable to retrieve a string from the Report Builder message file.
    OPP log for the same gives an output as under:
    Output type: PDF
    [9/21/10 2:17:12 PM] [UNEXPECTED] [388056:RT14415347] java.io.FileNotFoundException: /app/soft/test1udp/appsoft/inst/apps/e180r_erptest01/logs/appl/conc/out/o14415347.out (No such file or directory)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at oracle.apps.fnd.cp.opp.XMLPublisherProcessor.process(XMLPublisherProcessor.java:241)
         at oracle.apps.fnd.cp.opp.OPPRequestThread.run(OPPRequestThread.java:172)
    Report Builder 10g
    BI Publisher's version : 4.5.0
    RDBMS Version : 10.2.0.4.0
    Oracle Applications Version : 12.0.6
    Searched for the same on metalink and found Article ID 862644.1, other than applying patch and upgrading version of BI Publisher is there any other workaround to display a comma seperated string as long as 60k characters, If any please suggest.
    Thanks,
    Bhoomika

    Metalink <Note:1076529.6> extracts
    Problem Description
    When running a *.REP generated report file you get errors:
    REP-00002 Unable to retrieve string from message file
    REP-01439 Cannot compile program since this is a runtime report
    Running the same report using the *.RDF file is successful.
    You are running the report with a stored procedure,
    OR you are running against an Oracle instance other than the one developed on,
    Or, you recently upgraded your Oracle Server.
    Solution Description
    1) Check that the user running the report has execute permissions on any stored
    SQL procedures called. <Note:1049458.6>
    2) Run the report as an .RDF not an .REP , that is remove or rename the .REP
    version of the report. <Note:1012546.7>
    3) Compile the report against the same instance it is being run against.
    <Note:1071209.6> and <Note:1049620.6>

  • Exporting the Browse Sequence XML file for Use in Another Project

    When I generate a browse sequence based on the TOC using zero for the book level, instead of getting A, A1, A2, B, B1, B2, I get A, B, A1, A2, B1, B2.  The TOC runs through all 1st level items first, cycles back through all 2nd level item, then 3rd level, etc.
    My workaround was to auto-create the browse sequence at a 0 level and then manually manipulate it to output according to how my readers would actually read my online book (ie A Aa A1 A1a A1b A2 A2a A2b B B1 etc etc).
    Now that I have my browse sequence in the correct order for this project, I do not want to repeat these steps every time I create a new version of my OLH for the same guide after some minor updates have been made to the FM source.
    There is a file named whbrs.xml inside the output folder and it contains the browse sequence order I specified during my workaround steps.
    Is it possible to export this file to another location for use in another project referencing the same guide?
    This methodology is much preferred as I am working at an enterprise level with multiple documents (some numbering in the hundreds of pages) and do not want to have to manually use my workaround for each project I update over the next few years.

    Hi Kristopher
    You probably wouldn't want to use that particular file as it's an output file. You would likely have better luck using the ProjectName.BRS file as that one should be a source file.
    However, keep in mind that whether (or how well) this will work will entirely depend on having the recipient project using the same identical structure and identical file names.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Duplicate Loops. Not just in the browser - actual duplicate files.

    i have GarageBand loops located both in Library/Application Support/GarageBand/Apple Loops/Apple Loops for GarageBand and Library/Audio/Apple Loops/Apple/Apple Loops for GarageBand.
    as these are taking up space, which one can i safely delete - the one in Library/Audio or the one in Library/Application Support?

    You can remove the loops in Application Support; in fact that is the old location.
    But before to delete anything be sure that those are duplicates otherwise simply move them in the new location.
    cheers
    rob

  • Appending string to the start of a file problem

    Hi guys,
    I've got an xml file which i want to add a dtd to. So i'm using RandomAccessFile to seek the start of the file and write to it, but its seems to be overwriting a small part of my file. My code to this is below:
             try {
             RandomAccessFile f = new RandomAccessFile(xmlMap,"rw");
                f.seek(0);
            //write DTD definition to start of file
             f.writeChars("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+"\n"+
                     "<!DOCTYPE map SYSTEM \"mapDTD.dtd\">"+"\n");
             f.close();
             } catch(IOException e) {
                  System.out.println("ERROR with file name, game exiting");
                  System.exit(1);
             }If i take in this xml file:
    <map width="19" height="19" goal="6" name="Hallways of Dooom">
         <random-item type='lantern' amount='5' />
         <random-item type='health' amount='10' />
         <tile x="0" y="0" type="floor" />
         <tile x="1" y="0" type="floor">
              <renderhint>floor:wood</renderhint>
         </tile>
         <tile x="2" y="0" type="floor" />
         <tile x="3" y="0" type="wall" />
         <tile x="4" y="0" type="wall" />
         <tile x="5" y="0" type="wall">
              <renderhint>wall:bricks,cracked</renderhint>
         </tile>it gets overwritten as :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE map SYSTEM "mapDTD.dtd">
         <tile x="0" y="0" type="floor" />
         <tile x="1" y="0" type="floor">
              <renderhint>floor:wood</renderhint>
         </tile>
         <tile x="2" y="0" type="floor" />
         <tile x="3" y="0" type="wall" />
         <tile x="4" y="0" type="wall" />
         <tile x="5" y="0" type="wall">
              <renderhint>wall:bricks,cracked</renderhint>
         </tile>I want it so it is :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE map SYSTEM "mapDTD.dtd">
    <map width="19" height="19" goal="6" name="Hallways of Dooom">
         <random-item type='lantern' amount='5' />
         <random-item type='health' amount='10' />
         <tile x="0" y="0" type="floor" />
         <tile x="1" y="0" type="floor">
              <renderhint>floor:wood</renderhint>
         </tile>
         <tile x="2" y="0" type="floor" />
         <tile x="3" y="0" type="wall" />
         <tile x="4" y="0" type="wall" />
         <tile x="5" y="0" type="wall">
              <renderhint>wall:bricks,cracked</renderhint>
         </tile>
         <tile x="6" y="0" type="wall" />
         <tile x="7" y="0" type="wall" />
         <tile x="8" y="0" type="wall">
              <renderhint>wall:rock,cracked</renderhint>
         </tile>If anyone can see what's going wrong and how i can correct, i would greatly appreciate them saying so.
    Thanks a lot.

    javaUser wrote:
    Hi guys,
    I've got an xml file which i want to add a dtd to. So i'm using RandomAccessFile ...That's your mistake. Don't use random access file. It wasn't built for this situation and shouldn't be used for this situation. Do the right thing: rewrite the whole file.

  • How to close browser window after flushing a file to the browser?

    I have this simple JSP, which flushes a String to the browser as a file (message.txt). The JSP gets opened in a new window when the user clicks a link.
    The problem is that after the JSP has run, the browser window won't close automatically. I've tried adding a small javascript to achieve this, but i doesn't seem to even get run.
    How can I close the browser window after the JSP has run?
    <%
         String someText = "bla bla bla";
         // Flush to browser
         response.setContentType("text/plain");
         response.setHeader("Content-Disposition", "attachment;filename=message.txt");
         try {
              ServletOutputStream os = response.getOutputStream();
              os.write(someText.getBytes());
              os.flush();
              os.close();
         } catch (IOException e) {
              return;
         } catch (Exception e) {
              return;
    %>
    <script type="text/javascript">
         window.close();
    </script>After the JSP has run, an empty html page with the following source can be seen:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
    <BODY></BODY></HTML>

    Try run this and you'll see that it runs fine with no exceptions:
    <%
         String someText = "bla bla bla";
         response.setContentType("text/plain");
         response.setHeader("Content-Disposition", "attachment;filename=message.txt");
         try {
              ServletOutputStream os = response.getOutputStream();
              os.write(someText.getBytes());
              os.flush();
              os.close();
         } catch (Exception e) {
              out.println("ERROR: " + e);
    %>It looks like that after I've closed the outputStream I can't do any more processing in the JSP. Even if I remove the setContentType and setHeader methods it still behaves this way.
    I'm starting to think that there's no way around this...??

  • Forcing the browser to display current images

    Hi all
              I have a content manager tool where images are uploaded to a server.On the
              same screen the current version of the image is displayed
              When a new version of the image is uploaded and the page is requested again
              without closing the browser window), the old image displays unless the user
              clicks the refresh button or hits the F5 key.
              Is there a meta tag that will specifically expire images in the browser
              cache and force the browser to get the new version?
              I have tried various meta tags eg
              <meta http-equiv="Expires" content="0" />
              <META HTTP-EQUIV="REFRESH" CONTENT="-1">
              <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
              If the user closes the browser, opens it again and request the url then the
              new version of the image displays. It as though the cache doesnt flush or
              something until the browser is closed.
              The only other way I can think of is to add a ?param=some_random_number
              query string to each image in my html - not sure if that would work or not.
              Any help appreciated
              Thanks
              Matt
              

    Hi
              I ended up adding a randomly generated query string to all of my images that
              need to be reretrieved and it worked
              eg the url for my image would be images/myimage.gif?cacheparam=12345
              I did this instead of a custom filter/servlet because only about 3% of my
              images have these strict "ignore the cache" requirements and I couldnt think
              of a url pattern that would properly isolate them without also disabling
              caching for all of my other images.
              Thanks for your replies - i never thought of being able to set response
              headers individually for images.
              "Wenjin Zhang" <[email protected]> wrote in message
              news:[email protected]...
              >
              > I believe you can do that by adding HTTP headers in response object in
              your filter.
              >
              > "Matt Krevs" <[email protected]> wrote:
              > >Thanks
              > >
              > >Could I do this with a filter instead of a servlet?
              > >
              > >what headers would i set for each image?
              > >
              > >"Wenjin Zhang" <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> If you have a customized servlet to serve your images, you can add
              > >cache
              > >control
              > >> in HTTP header (not meta in HTML).
              > >>
              > >>
              > >> "Matt Krevs" <[email protected]> wrote:
              > >> >Hi all
              > >> >
              > >> >I have a content manager tool where images are uploaded to a server.On
              > >> >the
              > >> >same screen the current version of the image is displayed
              > >> >
              > >> >When a new version of the image is uploaded and the page is requested
              > >> >again
              > >> >without closing the browser window), the old image displays unless
              > >the
              > >> >user
              > >> >clicks the refresh button or hits the F5 key.
              > >> >
              > >> >Is there a meta tag that will specifically expire images in the
              browser
              > >> >cache and force the browser to get the new version?
              > >> >
              > >> >I have tried various meta tags eg
              > >> >
              > >> ><meta http-equiv="Expires" content="0" />
              > >> ><META HTTP-EQUIV="REFRESH" CONTENT="-1">
              > >> ><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
              > >> >
              > >> >If the user closes the browser, opens it again and request the url
              > >then
              > >> >the
              > >> >new version of the image displays. It as though the cache doesnt flush
              > >> >or
              > >> >something until the browser is closed.
              > >> >
              > >> >The only other way I can think of is to add a
              ?param=some_random_number
              > >> >query string to each image in my html - not sure if that would work
              > >or
              > >> >not.
              > >> >
              > >> >Any help appreciated
              > >> >
              > >> >Thanks
              > >> >Matt
              > >> >
              > >> >
              > >> >
              > >>
              > >
              > >
              >
              

  • Error in sending a binary outputstream to the browser

    I am looking for information on sending a binary outputstream to a browser.I am not getting any error and am able to write out the entire buffer.Even though the browser recognizes the mime type,it only sends junk to the client.Please look at the code sample below that I am using to send the outputstream.
    response.setContentType(MimeType);
    String str_encoding = response.getCharacterEncoding();
    System.out.println("================= The Character Encoding is --------------" + str_encoding);
    int len = buf.length;
    System.out.println("Data length ===========" + len);
    response.setHeader("Content-Disposition", "inline;filename=" + "\"" + fileName + "\"");
    OutputStream o = response.getOutputStream();
    int buffer_length = 10 * 1034;
    int offset = 0;
    //read a thousand bytes from the buffer at a time
    while ((offset <= buf.length) && (loop==true))
    if ((buf.length - offset) < buffer_length)
    buffer_length = buf.length - offset;
    loop = false;
    System.out.println("---------Now Inside the Loop, Writing Output Buffer ------" + offset + " bytes");
    o.write(buf,offset,buffer_length);
    o.flush();
    offset = offset + buffer_length;
    If anyone could tell me what needs to be done to successfully send a binary input stream from a Java application to a JSP page calling it and then successfully sending the outputstream for the client to be read,that would be fantastic.

    yes,I did.That sends the data out as junk.The outputstream gets some sort of junk characters with the response.getOutputStream() method.So it errors out when I set the content length.
    I tried sending the data as a whole,but does not seem to make a difference.I was grasping at straws when I tried to break it into chunks.

  • Viewing HTML page saved  on the server from the browser

    Hi all
    In my application i am having some HTML pages saved on the server. I had given an option to the user to view the HTML page from my application. behind the scene what i am doing is that the view request will get handled by a servlet and from that servlet iam locating the HTML page on the server directory and sending the HTML page to browser by using the Servlet OutputStream. The HTML page is shown on the browser but the attached images are not shown. The images are also there in the server directory and are refered in the HTML file correctly. When i directly open the HTML file then the images are shown correctly.
    Can anyone suggest wat's wrong there.
    The code i m using is
    ServletOutputStream out=response.getOutputStream();
                        if(format.equalsIgnoreCase("pdf"))
                             logger.info("Seleted format is pdf..\n");
                             response.setContentType("application/pdf");
                        else
                             logger.info("Seleted format is html..\n");
                             response.setContentType("text/html");
    String file = ReportingConstants.URL_GENERATEDREPORTS+reportPath+itemName;
    // file : HTML file absolute path as string.
                        URL url=new URL(file);                    
                        BufferedInputStream bis=new BufferedInputStream(url.openStream());
                        BufferedOutputStream bos=new BufferedOutputStream(out);
                        byte[] buff = new byte[2048];
                        int bytesRead;
                        while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                             bos.write(buff, 0, bytesRead);
                             bos.flush();
                        }

    You have to undertsand how the browser handles images and other resources in a HTML page. In the HTML there is an image tag that has a url to an image which can be a reletive url or an absolute url (starts with a "/").
    If the url is a relative url the browser interprets the url as being relative to the url currently displayed in the address field discarding the last element of the url . So if the url in the address bar is http://www.myserver.com/myapp/mypage.html and the relative url is images/myimage.jpg, the browser will submit a request to the server for http://www.myserver.com/myapp/images/myimage.jpg
    Now let's say that you are call mypage.html from a servlet that has the url http://www.myserver.com/myapp/servlets/myservlet. Then when the browser tries to retrieve myimage.jpg it will use the url http://www.myserver.com/myapp/servlets/myservlet/images/myimage.jpg and since this is incorrect it will not be able to display the images.
    One solution to this is to change all of the image urls to absolute urls. That is the start with a slash where the slash represents the start of the url after the application domain name. For example you used an absolute url for myimage.jpg it would look like /images.myimage.jpg and when accessing the page through the servlet url (http://www.myserver.com/myapp/servlets/myservlet) the browser will discard everything after http://www.myserver.com/myapp and look for the image at http://www.myserver.com/myapp/images/myimage.jpg which is the correct url.
    A second solution is to use the HTML BASE tag which tells the browser not to interpret the image tag urls (and other resourses) using the current url in the address bar but to use the url supplied in the HTML BASE tag. The browser will still perform the same process for relative urls but now relative to the BASE tag url. Since the BASE tag url will be the same every time the page is accesssed the images should be correctly accessed no matter how the page is accessed (eg directly, using RequestDistpatcher or via your servlet)

  • Should I export with ReportExportControl.processHttpRequest OR Java I/O libraries to write  result the browser ?

    Hi All,
    In our web deployment using JRC, we export to PDF on browser.
    There are two approach so far to achieve that  (codes attached below) :
    (1) Use ReportExportControl.processHttpRequest
    (2) Use the Java I/O libraries to write the exported result the browser
    The question is :
    Which one will take less bandwidth requirement / more efficient ?
    Or , is it just the same ?
    Thank you very much,
    xtanto
    The Codes :
    1) Use ReportExportControl.processHttpRequest
    ExportOptions oExportOptions = new ExportOptions();
                oExportOptions.setExportFormatType(ReportExportFormat.PDF);       
                ReportExportControl oReportExportControl = new ReportExportControl();
                oReportExportControl.setExportOptions(oExportOptions);
                oReportExportControl.setExportAsAttachment(false);            oReportExportControl.setReportSource(reportClientDoc.getReportSource());
                oReportExportControl.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
    2) Use the Java I/O libraries to write the exported result the browser
    ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
    reportClientDoc.close();
    writeToBrowser(byteArrayInputStream, response, "application/pdf", EXPORT_FILE);
    From the helper class :
        public static void writeToBrowser(ByteArrayInputStream byteArrayInputStream, HttpServletResponse response, String mimetype, String exportFile) throws Exception {
                        //Create a byte[] the same size as the exported ByteArrayInputStream.
                        byte[] buffer = new byte[byteArrayInputStream.available()];
                        int bytesRead = 0;
                        //Set response headers to indicate mime type and inline file.
                        response.reset();
                        response.setHeader("Content-disposition", "inline;filename=" + exportFile);
                        response.setContentType(mimetype);
                        //Stream the byte array to the client.
                        while((bytesRead = byteArrayInputStream.read(buffer)) != -1) {
                                response.getOutputStream().write(buffer, 0, bytesRead);
                        //Flush and close the output stream.
                        response.getOutputStream().flush();
                        response.getOutputStream().close();

    With the JRC, the PDF generation engine would be the same.
    One advantage of the PrintOutputController is that it gives you more control over the output - where it goes, how it's streamed out, etc.
    (Aside note: for BusinessObjects Enterprise Java SDK, the ReportExportController would be more efficient, since you can specify the Page Server rather than RAS server to create the output.)
    Sincerely,
    Ted Ueda

  • Getting Error 500 when pressing the backbutton of the browser after log out

    I am working on a web project , and am using AJAX in my application. I need to get list of templates and events stored in the database when my page is being loaded so im using AJAX. the problem is, when i press the logout in my page and after logging out if i press the browsers back button then im getting the Http Error 500.
    Regarding this issue i previously also posted but i havent get solved my problem. (may be i havent posted my source code , rather i just posted error message.).
    Here is the error message of the browser,
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
         com.koffee.eon.subscriber.action.TemplateNames.doPost(TemplateNames.java:66)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
    Here is my source code of the TemplateNames class,
    package com.koffee.eon.subscriber.action;
    import com.koffee.eon.subscriber.persistence.*;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.text.SimpleDateFormat;
    import java.util.*;
    public class TemplateNames extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         String html="",html1="";
         HttpSession session=request.getSession();
         UserCompleteDetails sessionDetails=(UserCompleteDetails)session.getAttribute("userdetails");
         System.out.println("checking session after logout"+sessionDetails);
         if(sessionDetails==null)
         System.out.println("session details in if condition is:"+sessionDetails);
         response.sendRedirect("/login.jsp");
         System.out.println("after checking "+sessionDetails);
         String type=null;
         type=request.getParameter("type");
    String subscriberUserEONId=sessionDetails.getUserEonId();
    System.out.println("subscriberUserEONId from session is: "+subscriberUserEONId);
         SimpleDateFormat sdfDate=new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat sdfTime=new SimpleDateFormat("HH:mm:ss");
         TemplateManagement dbObj=new TemplateManagement();          
    EventManager dbObj1=new EventManager(); // for events
         List templateNames=dbObj.getTemplates(subscriberUserEONId);
         List eventIds=dbObj1.getEventsCompleteList(subscriberUserEONId); // for events
         System.out.println("size of list of templates is:" + templateNames.size());
         System.out.println("size of list of events is: "+eventIds.size()); // for events
         if(type==null)
         html+="<table><tr><td>Select Your Invitation Card: ";
         html+="<select name=\"templateName\" class=\"cell\" onchange=getImage(this.value) onblur=checkTemplate() tabindex=\"1\">";
         html+= "<option value=\"0\">Select</option>";
         HashMap hmap=new HashMap();
         try {
         for(int i=0;i<templateNames.size();i++) {
         TemplateMaster bean=(TemplateMaster)templateNames.get(i);
         Integer templateid=bean.getTemplateId();
         String templatepath=bean.getTemplateRelevantpath();
         hmap.put(templateid,templatepath);
         System.out.println("path recevied from db for template is: "+templatepath);
    System.out.println("template id received from db is : "+templateid);
         html+= "<option value=\"" + templateid + "\">" + templateid + "</option>";
         } catch(Exception ee) {ee.printStackTrace();}
         session.setAttribute("hmap", hmap);
         html+="</select></td></tr><tr><td>";
         System.out.println("path new is : "+html);
         html+="</td>";
         System.out.println(html);
    html+="</td></tr><tr><td>Select an Event: ";
              html+="<select name=\"eventId\" class=\"cell\">";
              try {
         for(int j=0;j<eventIds.size();j++) {
         EventMaster bean=(EventMaster)eventIds.get(j);
         String eventName=bean.getEventName();
         Integer eventId1=bean.getEventId();
         String eventStartDate=sdfDate.format(bean.getEventStartdate());
         String eventStartTime=sdfTime.format(bean.getEventStarttime());
         String eventId=eventName+" on "+eventStartDate+" at "+eventStartTime;
         System.out.println("event id from database is : "+eventId1);
         System.out.println("event list from database is : "+eventId);
         html+= "<option value=\"" + eventId1 + "\">" + eventId + "</option>";
         } catch(Exception eee) {eee.printStackTrace();}
         html+="</select></td></tr></table>";
         System.out.println(html);
         out.println(html);
         out.flush();
         out.close();     
         if(type!=null)
         html1+="</td></tr><tr><td>Select an Event: ";
         html1+="<select name=\"eventId\" class=\"cell\">";
         try {
         for(int j=0;j<eventIds.size();j++) {
         EventMaster bean=(EventMaster)eventIds.get(j);
         Integer eventId1=bean.getEventId();
    String eventId2=eventId1.toString();
         String eventName=bean.getEventName();
         String eventStartDate=sdfDate.format(bean.getEventStartdate());
         String eventStartTime=sdfTime.format(bean.getEventStarttime());
         String eventId=eventName+" on "+eventStartDate+" at "+eventStartTime;
         System.out.println(eventId);
         html1+= "<option value=\""
    + eventId2 + "\">" + eventId + "</option>";
         } catch(Exception eee) {eee.printStackTrace();}
         html1+="</select></td></tr></table>";
         out.println(html1);
         out.flush();
         out.close();     
    }

    chinni wrote:
    java.lang.NullPointerException
         com.koffee.eon.subscriber.action.TemplateNames.doPost(TemplateNames.java:66)Do you understand when a NPE will be thrown? Some object reference at line 66 of TemplateNames.java is null while you didn't expect and you still invoke/access it. To fix this, add a nullcheck or just instantiate the reference.

  • Opening a Document (.doc, .xls, .pdf) in the browser using an action

    Hello
    I´m using JavaScript to open a document in the browser using the property Onclick from Command Button: onclick="#{backing_archivos.rutaArchivo}"
    and in the backing_archivos.rutaArchivo I have the String window.open("file://c://tmp/document.pdf", "title page", "top=100, left=100")
    but the browser doesn't open anything.
    What can I do?
    Thank.

    You can do an external file by using a stream and and the response object. I have this in a backing bean, and it gets called with a command button.
    public String runQCReport_action()
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("PromotionRequestQCReport");
    Object result = operationBinding.execute();
    FileInputStream bis = null;
    ServletOutputStream bos = null;
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
    response.setContentType("application/pdf");
    response.setHeader("Content-disposition","inline=filename=file.pdf");
    try {
    File fileName = new File("applications/reports/output/PromotionRequestQCReport.pdf");
    bis = new FileInputStream(fileName.getAbsolutePath());
    bos = response.getOutputStream();
    byte[] buff = new byte[2048];
    int bytesRead;
    while (-1 !=(bytesRead = bis.read(buff,0,buff.length)))
    bos.write(buff,0,bytesRead);
    //response.getOutputStream().write(yourdata[]);
    response.getOutputStream().flush();
    response.getOutputStream().close();
    context.responseComplete();
    catch (IOException e) {
    e.printStackTrace();
    return null;
    }

  • Does the sharedObject get destroyed when the browser is closed?

    hey guys, so i just wanted to make sure that when my internet browser is closed it destroys or clears my sharedObject??
    right now i wasnt sure so im doing somehting like the following
    public var sharedObj:SharedObject;
    if(sharedObj != null){
         sharedObj.clear();
    sharedObj = SharedObject.getLocal(...);
    i just wnated to make sure that this is the most effective way to destory the sharedObject just in case there is one left in the browser...
    is there another way to make sure i clear the sharedObjects??

    hello cyber0897,
    No sharedObjects are stored in a cookielike textfile on the clients harddrive, As far as I know there is not an option like with cookies to be destroyed after the browser closes.
    The reset you wrote should be in another order:
    var mySharedObject:SharedObject = SharedObject.getLocal....
    //the above will never give null, because it is created when it doesnt exist.
    //the if (object != null) is useless because of the above, in your post it will be always null, since it is not instantiated...
    mySharedObject.clear();
    mySharedObject.flush(); //not sure if this is neccesary
    You could reset the sharedObject when initializing your application, but if you just want to store variables and get them wherever you need them in your app you could use the singleton class below
    Usage:
    <s:TextInput id="text1" text="@{PrefObj.instance.myString} />
    <s:TextInput id="text2" text="@{PrefObj.instance.myString} />
    (the @ only works in flex 4)
    PrefObj.as
    package
        import flash.events.EventDispatcher;
        [Bindable]
        public final dynamic class PrefObj extends EventDispatcher {
            private static var _instance:PrefObj = new PrefObj();
            public function PrefObj(){
                if (_instance != null){
                    throw new Error("PreferencesManager can only be accessed through PreferencesManager.instance");
            public static function get instance():PrefObj {
                return _instance;
            //add your variables here:
            public var myString:String = "";  

  • Determening type of the browser with JSP

    Is there a way to determine type and version of the browser with JSP?
    I need to determine if the borowser is IE 5.5 or IE 6.0
    Thanks

    String fileName ="c:/test1.pdf";
      File file = new File(fileName);
       if(!file.exists())
         return;
      // If JSP
      String mimeType = application.getMimeType(fileName);
           If you are using servlet
           String mimeType = this.getServletContext().getMimeType(fileName);
         response.setContentType(mimeType);  
         response.setHeader("Content-Disposition","inline;filename=\\"+fileName+"\\");
      BufferedOutputStream out1 = null;
      InputStream in = null;
      if(mimeType == null)
         mimeType = "application/octet-stream";
      try{
         in = new FileInputStream(f);
         response.setContentLength(in.available());
         BufferedOutputStream out1 = new BufferedOutputStream(response.getOutputStream(),1024);
         int size = 0;
         byte[] b = new byte[1024];
         while ((size = in.read(b, 0, 1024)) > 0)
            out1.write(b, 0, size);
      }catch(Exception exp){
      }finally{
          if(out1 != null){
             try{
                out1.flush();               
                out1.close();
             }catch(Exception e){}
          if(in != null){
            try{in.close();}catch(Exception e){}
      } this is what either your JSP/SERVLET/Backing Bean is supposed to do.
    please try to restructure your code as per it.
    Hope that might help :)
    REGARDS,
    RaHuL

Maybe you are looking for

  • I am unable to install the CSXS Infrastructure 4.0.2 update

    Every day I can see the adobe cc update icon, it makes me feel very bad, but always be updated each time an update fails, which is why this road is not? There are pictures and the truth: No matter how retry, the result is the same: Update failed! Ple

  • Error while installing OBIEE 11.1.1.7 on Linux

    Hi, I am trying to do OBIEE 11.1.1.7 Enterprise install on a Linux server. When I run the installer, after specifying install location, when I configure the components(Select BI Enterprise Edition, BI Publisher) I get error as ORACLE_HOME variable is

  • No sound on start up

    Hi We have been on holiday recently and while away my youview box updated. Since then when switching the box on from standby and switching on the tv I do not get any sound. If I then change channel the sound comes on. Has anyone else got this problem

  • DIRECT TECH SUPPORT?

    Whenever I have a problem with iMovie HD or iDVD ( I use them both for my videography business) I always end up searching for answers on the discussions board. That's great and many of you have taught me quite a bit about the software. But I do have

  • BUPA_DEL: Business partner  still used in business transactions

    Hello, I try deleting some out-dated Business Partners by tr. BUPA_DEL. But the transaction prevents from deleting BPs saying "Business partner  still used in business transactions". But I can not find in what business transactions  these BPs are use