Stream Output problem when filename has Period( . ) within it in Servlet

I have this code below that outputs the pdf file from a JSP using a servlet. The problem is if filename has period (.) (Ex. AAA.BBB.CCC.PDF) within it I gey a socket write error, and cant output the pdf file. Can anyone help me with this.
Thank You
JSP Code:
document.write("<object classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" id=\"BravaDTXView1\" width=\"100%\" height=\"100%\"> ");
document.write(" <param name=\"src\" value=\"/TifPdfDisplay?filepath=<%=sFilepath>\"> ");
document.write("</object>");
Servlet Code:
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding(Constants.GlobalVariable.CHARSET);
String sFilePath= (String) request.getParameter("filepath");
// Read in PDF test file
File l_file = new File(sFilePath);
FileInputStream in = new FileInputStream(l_file);
int length = in.available();
byte[] pdfbytes = new byte[length];
in.read(pdfbytes);
in.close();
// Send response
response.setContentType("application/pdf");
response.setContentLength(pdfbytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(pdfbytes, 0, pdfbytes.length);
ouputStream.flush();
ouputStream.close();
}

Hi all,
I happen to solve the problem myself. The solution is striking simple. Just reduce the image size & bingo!
Regards

Similar Messages

  • Output problem when filename has Period( . ) within it in Servlet

    I have this code below that outputs the pdf file from a JSP using a servlet. The problem is if filename has period (.) (Ex. AAA.BBB.CCC.PDF) within it I gey a socket write error, and cant output the pdf file. Can anyone help me with this.
    Thank You
    JSP Code:
    document.write("<object classid=\"clsid:CA8A9780-280D-11CF-A24D-444553540000\" id=\"BravaDTXView1\" width=\"100%\" height=\"100%\"> ");
    document.write(" <param name=\"src\" value=\"/TifPdfDisplay?filepath=<%=sFilepath>\"> ");
    document.write("</object>");
    Servlet Code:
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding(Constants.GlobalVariable.CHARSET);
    String sFilePath= (String) request.getParameter("filepath");
    // Read in PDF test file
    File l_file = new File(sFilePath);
    FileInputStream in = new FileInputStream(l_file);
    int length = in.available();
    byte[] pdfbytes = new byte[length];
    in.read(pdfbytes);
    in.close();
    // Send response
    response.setContentType("application/pdf");
    response.setContentLength(pdfbytes.length);
    ServletOutputStream ouputStream = response.getOutputStream();
    ouputStream.write(pdfbytes, 0, pdfbytes.length);
    ouputStream.flush();
    ouputStream.close();
    }

    Hi,
    Yes my problem is already solved.
    I created a report which creates the sapscript and in my function module I just execute that report.
    So problem solved :-).
    Greetings;
    Frederik

  • Smartforms - problems with output preview when vedor has different languag

    Hi all,
    The output preview does not work when vendor has different communication language then english?
    Exact description of the problem described by the functional people:
    "For the Latin America countries that use the SMARTFORM today, we have noticed that if the vendor has ‘communication language’ English, the PO is displayed fine in the ‘Output preview’ in iShop. However, if the vendor has communication language e.g. ES maintained in the vendor the output preview fails. We would like to have it so that even if the the vendor has a different communication language than EN maintained on the vendor the PO should be able to be displayed in the ‘output preview’ of the SRM system."
    So has enyone encountered this problem before? All help is appriciated!
    Thanks in advance!
    /Armin

    Well the problem was that the language pack with Sapnish language was not installed.
    Thanks for the answer 2p 2u!

  • Get current PDF path when filename has unicode chars

    How do i get the current PDF path if the filename has unicode characters
    Thanks
    Swapneel

    How are you getting it now that it isn't working?

  • When I download photos to my I-Mac and then try to open them,  It says that I don't have permission to view them. I have been using the computer for several months without this problem, but it has appeared within the last two weeks.

    When I try to open my downloaded photos from a DVD through finder the computer says that I don't have permission to view the files.
    This is something that has just happened recently.

    Copy the images to your Pictures folder or Desktop and then try again.
    If that doens't work, then do #6 here, (Reset Home Directory Permissions and ACLs)
    that will set the permissions to you.
    ..Step by Step to fix your Mac

  • Is there a way to have Firefox respect the default audio output device when it has been changed while Firefox is open?

    I have been a Firefox user for many years and I still use it as my primary browser. One problem that has bothered me for years is the fact that when Firefox is open and I change my default audio output device, Firefox doesn't respect that change and continues playing audio through the device that was originally being used. Even if you stop the audio and continue playing, the output device doesn't change.
    Is there any way this can be configured in Firefox? Now if I listen to music online (e.g. Soundcloud) I always use Chrome since it's respects the default audio output device change even while in the middle of playing audio.
    Reproduce:
    1. Start playing audio (e.g. from a YouTube video; HTML5 and Flash are affected)
    2. Change your default audio output device
    3. Audio will continue to play from original output device
    Thanks!

    This is the same issue that has plagued me for years. I always thought that this was a Flash plugin issue, but it does occur on HTML5 as well. A friend of mine verified that this does not occur in Linux, but only on Windows. It would be great to have this fixed, as it's honestly the only thing that's making me use Chrome all the time, as I don't want to have multiple browsers open.

  • Audio Output problem when connected to car port

    Just switched to an iPhone 4 from the 3G model. When I play any audio (music or Pandora)while connected to my car port, I get bits of noise at timed intervals coming throught the speakers. I would say it is about every 2-3 seconds I get this little added noise sample added to the audio stream. My old phone and ipod classic work great so I know it is not the car deck. The headphone mini connector produces clean audio.
    Anyone else have this?
    This in addition to the other problems that seem to be inherent in this new device has me thinking about returning the phone tonight.

    Well it turns out a hard reset of the phone did fix the audio. My car stereo installer told me to do that and it worked!

  • Problem when creating sapscript from within function module

    Hi,
    I created a function module which retrieves some master data, creates a sapscript for displaying the data and finally converts the sapscript to an otf. Afterwards the otf is converted to a pdf file.
    The problem is that the pdf file is created but it is empty!
    Here is a piece of the code:
    FUNCTION zhr_display_jobdescrpdf.
    * To access the SAP script output in OTF format.
    struct-tdgetotf = 'X'.
    struct-tdprogram = SY-REPID.
    CALL FUNCTION 'OPEN_FORM'
         EXPORTING
    *           APPLICATION        = 'TX'        " this is SapScript Appl
              device             = 'PRINTER'   " allow output to printer
              dialog             = 'X'         " printer dialog requested
              form               = 'ZHR_JOB_DESCR'       " name of form (SE71)
              language           = 'E'
              OPTIONS            = struct
    CALL FUNCTION 'START_FORM'
    EXPORTING
    *   ARCHIVE_INDEX          =
       form                   = 'ZHR_JOB_DESCR'
       language               = 'E'
    *   STARTPAGE              = ' '
    *   PROGRAM                = ' '
    *   MAIL_APPL_OBJECT       =
    *   IMPORTING
    *   LANGUAGE               =
    CALL FUNCTION 'WRITE_FORM'
         EXPORTING
           element                        = 'TEXT'
           function                       = 'SET'
           type                           = 'BODY'
           window                         = 'MAIN'
    CALL FUNCTION 'END_FORM'
    * IMPORTING
    * RESULT =
    EXCEPTIONS
    CALL FUNCTION 'CLOSE_FORM'
    * IMPORTING
    * RESULT =
    * RDI_RESULT =
    TABLES
    otfdata = datab[]
    EXCEPTIONS
    ENDFUNCTION.
    The content of datab[] is:
    1     //     XHPLJIIID    0700 0000000000
    2     IN     01EZHR_JOB_DESCR   MAIN
    3     OP     DINA4   P 144  240 1683811906000010000100001
    4     IN     02MAIN
    5     EP
    6     //
    So none of the variables that are used in the sapscript were transferred, although they are filled with the correct values when I put a breakpoint on the function 'write_form'. It looks like the sapscript can't access variables that are declared in a function module.
    Putting all the code for creating the sapscript in a report is not an option because then I have to use export/import to/from memory for retrieving the otf data and this doesn't work with the sap portal where the function is called.
    Did anyone had the same or similar problem?
    Greetings,
    Frederik

    Hi,
    Yes my problem is already solved.
    I created a report which creates the sapscript and in my function module I just execute that report.
    So problem solved :-).
    Greetings;
    Frederik

  • At selection screen output problem when a field is obligatory

    Hi All,
    I have two radiobuttons on the selection screen and when I select first radiobutton one screen should display and the other should not be displayed and vice-versa. It is working fine if I do not have a mandatory field.I am pasting my code here.Can anyone please help me how to handle this situation when we have some mandatory fields on one of these screens.
    TABLES : mara,marc.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS : p_meth1 RADIOBUTTON GROUP g1 USER-COMMAND g1,
                 p_meth2 RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK matnr WITH FRAME TITLE text-002.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS : so_matnr FOR marc-matnr MODIF ID m1 obligatory.
    SELECTION-SCREEN SKIP 1.
    SELECT-OPTIONS : so_werks FOR marc-werks MODIF ID m1 .
    SELECTION-SCREEN END OF BLOCK matnr.
    SELECTION-SCREEN BEGIN OF BLOCK file WITH FRAME TITLE text-003.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS: p_fpath TYPE ibipparms-path MODIF ID m2 LOWER CASE.
    SELECTION-SCREEN END OF BLOCK file.
    SELECTION-SCREEN BEGIN OF BLOCK date WITH FRAME TITLE text-004.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS : p_date TYPE datuv.
    SELECTION-SCREEN END OF BLOCK date.
    AT SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN.
    CASE screen-group1.
    WHEN 'M1'.
    IF p_meth1 = 'X'.
    screen-active = 1.
    ENDIF.
    IF p_meth2 = 'X'.
    screen-active = 0.
    ENDIF.
    WHEN 'M2'.
    IF p_meth2 = 'X'.
    screen-active = 1.
    ELSE.
    screen-active = 0.
    ENDIF.
    IF p_meth1 = 'X'.
    screen-active = 0.
    ENDIF.
    ENDCASE.
    MODIFY SCREEN.
    ENDLOOP.
    Thanks in advance
    Sandeep

    Obligatory fields with your requirement will not work, reason : The GUI checks obligatory fields before passing the control back to the program (i.e Before triggering the PAI )
    If you check for empty fields and give appropriate error message in the PAI, the program will not allow you to switch to the other radio button until you fill something in the fields because the moment you select a radiobutton, it will validate the field and issue the error message.
    So it is like a catch 22 situation.
    All you can really do is to check see which radio button is clicked and then do your processing. Also make sure to assign a user command to the radiobutton and query it in the AT SELECTION SCREEN and based on the radiobutton selected, decide which fields should be validated.
    " Additon...
    INITIALIZATION  " Default values
    p_meth1 = 'X'.
    AT SELECTION-SCREEN.  " General PAI
    if p_meth1 EQ 'X'.
    "validate fields for meth1.
    elseif p_meth2 EQ 'X'.
    " validate fields for meth2.
    endif.
    regards,
    Advait

  • Excise Problem when inventory is transferred within same location

    Dear Experts,
    I am using SAP 2007 B PL10. Whenever i am transferring inventory from one warehouse to another warehouse (for e.g. stores, quality, rejection, etc) and if all the warehouse and items are excisable then the system is asking me for outgoing excise invoice for the inventory transfer even though the items are being moved within the same location. Pls let me know how can the same be avoided.
    Regards,
    Rahul

    For more details check below document.
    SAP Business One 2007B Indian Localization Enhancements document - Excise on Stock transfer
    https://websmp209.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000680297&_SCENARIO=01100035870000000183&_ADDINC=011000358700002837782005E&
    Jeyakanthan

  • A problem when using Sun One to create a Servlet?

    I have the Sun One Application Server installed on my computer. I used the Sun One Studio to create my first Servlet: HelloServlet. The steps are as following:
    1)First, the filesystem I mounted on Sun One Studio is:
    D:\myProgram\John\JohnEJB1.
    2)Then I created a folder(or package) under it, it�s called client. I created a html file, hello.html under this client folder, which will call a servlet later. Immediately, I transferred this client folder to a Web Module. So there is a WEB-INF under the D:\myProgram\John\JohnEJB1 in the Sun One Studio. This WEB-INF of course has one classes folder and one lib folder.
    3) Under this classes folder, which is used to save all the Servlet classes, I put my HelloServlet.java.
    4) in the web.xml, I put the following:
    <servlet>
    <servlet-name>MyHello</servlet-name>
    <display-name>MyHello</display-name>
    <servlet-class>samServlet. HelloServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MyHello </servlet-name>
    <url-pattern>/samTest</url-pattern>
    </servlet-mapping>
    5) Again, in the html file hello.html mentioned earlier, I put the Action like this: <FORM METHOD="GET" ACTION="/samTest">
    6) Finally, I deployed this WEB-INF to the Sun One Application Server.
    But when I went to the url: http://localhost: 80/client/hello.html to test it, when I clicked the Form Button, in other words, when the html file called the Servlet, it failed. It reported some error like NoClassDefFoundError.
    Anyone who can point out which part was wrong here? I know it�s a very basic problem. So I really appreciate your help.

    The classes folder should contain class files, not java files.

  • My apple Tv has audio problems when streaming from my NAS server.

    My Apple TV has audio problems when streaming from my NAS server or computer and even internet. I can hear the click sound it makes when you click on the icons, but when the movie starts there is no audio. This even happens when using XBMC. I have HMDI directly to my TV suing Apple TV 2. I have tried resetting, turning off both TV and Apple TV, and changing the HDMI cable. It is driving me nuts.

    XMBC requires a hack, we cannot help with hacked devices.

  • Problems when waking from long sleep periods

    Suddenly this morning my iMac developed a problem when recovering from a long period of sleep. I'm having trouble finding a solution.
    I have my iMac set to ask for password when it recovers from sleep or screen saver. When I woke my iMac this morning the password dialog box appeared at the top of the screen as a garbled mess. If I put my iMac back to sleep and then wake it again it usually solves the problem.
    I don't want to turn password verification off. Has anyone seen this problem before? Any suggestions on what might be cause?

    funkyblue:
    I usually leave my Pismo on and allow it to sleep. I find that waking from sleep and general functioning of the computer works a lot better if from time to time (I do it at least weekly) I shut down the computer, start up in Safe Mode, log in, empty Trash and reboot normally. The emptying Trash part clears the font caches.
    You should consider doing other maintenance procedures, if you don't already. Gulliver's Mac OS X System Maintenance has good ideas with linked resources.
    Please do not hesitate to post back with further questions or comments.
    Good luck.
    cornelius

  • 2.2 update causes problems when fastforwarding through streamed videos

    Has any else exprienced problems when trying to fast forward or skip to later sections of a large movie file (>1 gig) that is being streamed from a shared network folder? After the 2.2 update the file often not play after FFwarding but rather continuously tries to 'load' the file - the loading bar usually gets to about 99% but never to 100%. This problem was not existent for me with the 2.1 software.

    After doing a factory re-install of ATV 2.1 software (from 2.2) the streaming worked just fine again with my mac mini and router. There are reasonable seek delays but not like in 2.2 where the delay is indefinite. My iTunes library is being streamed from a USB harddrive attached to my mac mini. My LAN setup is wired so the problems I am experiencing is not due to wifi lag.
    All of my files that I am attempting to stream are large, single chapter videos. I doubt it is a chapter issue, however, as even fast forwarding hangs the video playback after a few seconds of seeking.

  • I have a problem when buying from within the game

    I have a problem when buying from within the game
    i used visa..

    All games? Settings > General > Restrictions has an option to prevent In-App Purchases. Is that on?

Maybe you are looking for

  • Unable get complete filepath from jsp page using request.getParameter()

    Hey all, i am actually trying to get the selected file path value using request.getParameter into the servlet where i will read the (csv or txt) file but i dont get the full path but only the file name(test.txt) not the complete path(C:\\Temp\\test.t

  • Can not sync photos with iPad or iPhone after upgrade to lion

    I upgraded to lion and now i get an error message saying could not sync photos with Ipad as they can not be viewed on the ipad.  I lost everything when i upgraded and had to reload all my files using a new user. Now i cant sync my photos with my ipad

  • Autosave in Illustrator CS4?!

    Hi good afternoon.  My name is Joan, and was working with Adobe Illustrator CS4 and kept my job at the end of the file, then I closed the program and asked if I wanted to replace the file and I said yes, thinking it would keep just the last change. B

  • How to create a background job for call transaction

    hi gurus can any one suggest me how to create the background job for call transaction. thank you regards kals.

  • 403 Forbidden comes up when I try to set up a localhost

    When I get to checking whether WampServer is installed properly on my computer, it asks me to open up the web browser and navigate to http://localhost. When I do that, the page say "Forbidden You don''t have permission to access / on this server" The