My code servlet JasperViewer report mode more download it in pdf in chrome. How to modify this code it gives only the view in JasperViewr?

Mr President.

My servlet code does two things

1 see the report in JasperViewer

2. it download it in pdf in chrome.

How to modify this code it gives only the view in JasperViewr?

My code is

package esh.view;


import esh.model.AppModuleImpl;


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;


import java.util.HashMap;
import java.util.Locale;
import java.util.Map;


import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;


import net.sf.jasperreports.view.JasperViewer;


import oracle.jbo.client.Configuration;


@WebServlet(name = "MultiReportServletJasper", urlPatterns = { "/multireportservletjasper" })
public class MultiReportServletJasper extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=UTF-8";


    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }


    protected Connection getConnection() {
            
            PreparedStatement st = null;
            String amDef = "esh.model.AppModule";
            String config = "AppModuleLocal";
            AppModuleImpl am = (AppModuleImpl ) Configuration.createRootApplicationModule(amDef, config);
            
            st = am.getDBTransaction().createPreparedStatement("select 1 from dual", 0);
            Connection conn = null;    
        
            try {
                conn = st.getConnection();
                return conn;
            } catch (SQLException e) {
            }   
        
            return null;
        }


    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String var0 = "";  
        String reportName = "";  
        try {  
             reportName = request.getParameter("reportName");  
            } catch (Exception e) {  
                    e.printStackTrace();  
                   }  
             response.setContentType(CONTENT_TYPE);  
             Map parameters = new HashMap();  
             parameters.put("format", "pdf");  
             parameters.put("WEBDIR", getServletContext().getRealPath("/"));  
             parameters.put("REPORT_LOCALE", new Locale("ar"));                             
                                                                                        
             Connection conn = null;  
             InputStream is = null;  
        try  
            {  
             conn = getConnection();  
             is = getServletContext().getResourceAsStream("/WEB-INF/reports/"+reportName+".jrxml");  
                          
                         
             response.setContentType("application/pdf");  
             response.addHeader("Content-Disposition", "attachment; filename="+reportName+".pdf");                                        
             JasperDesign jasperDesign = JRXmlLoader.load(is);  
             JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);  
             JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);                      
             JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());  
             JasperViewer.viewReport(jasperPrint,false);                                                                                
              conn.close();  
            }  
               catch (Exception e) {  
                     e.printStackTrace();  
                } finally {  
                    closeConnection(conn);  
                try {  
                       if(is !=null){  
                          is.close();  
                     }                                                             
            } catch (Exception localException1)  
                {  
                  }  
            }                      
    }
    
    protected static void closeConnection(Connection conn) {
            try {
                if(conn !=null){
                   conn.close();
                }           
            } catch (Exception ex) {
                //  System.out.println("Developer Msg : Exception in printReport1Servlet.closeConnection()");
            }
        }
    
    
}




























Concerning

Change: response.addHeader ("Content-Disposition", "attachment; filename = "reportName +".pdf");"

To: response.addHeader ("Content-Disposition", "inline; filename = "reportName +".pdf");"

Browser first tries to show the PDF, and if no pdf reader is available, you will get the download dialog box.

(and remove JasperViewer.viewReport (jasperPrint, false);  )

Dario

Tags: Java

Similar Questions

  • Lightroom will not update to Blurb to create a book; also not download to a pdf file.  How can I fix it?

    Lightroom will not upload to Blurb to create a book; also will not download to create a pdf file.  How can I fix it?

    Could you please create a new Collection and then check with the new collection.

  • Trying to install: WindowsXPMediaCenter2005-KB900325-usa__but I discovered that I also need this, but it gives me the error code 1706: KB867460 - NDP1.1sp1 - X 86

    Hello, I have Windows Media Center, and I tie to get the 2 Roll-up so I can connect my computer to my xbox, but I need to do this: WindowsXPMediaCenter2005 KB900325-United States, but it will not install. I think the problem is that I do not have this: NDP1.1sp1 - KB867460 - X 86

    But when I try to install that, I get the error code 1706

    And Yes, I checked the solution to this on the support Web site, and it says to install the Net 1.1 sp1 which as I have said, does not install

    I have checked the updates in my Add & Remove Programs, and I have no patch 1.1 (but take note I have two 1.0 patches) which is something that my computer can not have on it in order to install Net 1.1 sp1

    So yes, I tried to call microsoft for some time, but can not get a person, and the machine cannot help. I also tried the Fix - it program. So yes, I could really use some help, I tried to understand this for quite awhile.

    Thank you.

    P.S. Don't copy and paste this, that of what I tried to do http://support.microsoft.com/kb/900325...

    Edit: I did a search in all files and folders, and my computer found no netfx.msi (I also tried to run) which is the place where I think that my computer wanted Net 1.1 sp1 must be installed...

    Hello
     
     
    a. create a folder named 'Framework' at the root of the C: drive.
    i. open workstation.
    II. right-click on "Local disk, C:" and select 'open '.
    III. on top of windows, select 'File' and then 'new' then 'folder '.
    IV. This will create a new folder and leave the cursor in the box .and files name 'framework '.
     
    and save it in the C:\Framework folder
     
     
    and save it in the C:\Framework folder
    (d) extract the required files by running the following commands from the
    Start-Run dialog box:
    C:\Framework\dotnetfx.exe t:c:\framework\extracted\ / c
    e. clear the Temp folder:
    i. Select 'Start' and then 'run '.
    II. Type "%temp%" without the quotes, and then select OK.
    III. delete all the files found and if they won't erase continue to another.
    f. install .NET Framework 1.1 SP1 of
    c:\framework\NDP1.1sp1-KB867460-x86.exe, if this attempt fails for some reason any
    Please, do the following and send me the c:\sp1.log that results.
    g. remove the SP in the root of C by using the following command from the
    Start, and then run the dialogue:
    C:\Framework\NDP1.1sp1-KB867460-x86.exe /xp:c:
    h. do the following to install the connection using the following command
    from the start-> Run dialog box:
    msiexec /p c:\S867460.msp/l * v c:\sp1.log REINSTALL = ALL
    * If the file is not found, please do the following as we saw some
    systems to extract the file in the local folder instead.
    msiexec /p c:\framework\S867460.msp/l * v c:\sp1.log REINSTALL = ALL
    I. Si you are prompted for the 'netfx.msi' navigate to the location
    c:\framework\extractedetfx.msi, Installation should continue without
    error.

    I hope this helps.
     

    Thank you, and in what concerns:
    Shekhar S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.
    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • I have CC 2015 for Macbook pro want to download on iPad and iPhone. How to do this?

    How can I download CC 2015 for iPad and iPhone.  Have CC 2015 desktop

    Peter,

    The Adobe Creative Cloud Desktop app is for Mac and PC, but there is an app on iTunes you can download: Adobe Creative cloud on the App Store on iTunes. The application makes it easy to download your files or photos from your iPad or iPhone to your creative space Cloud. You can then synchronize the files downloaded on your other computers or share files directly on Behance.

    See this link for more information:

    Using creative cloud | Creative cloud for iOS

    Kind regards

    Guinot

  • I have Firefox 7.0.1 and want to move forward and back more than one page at a time-how to fix this?

    I used to have 6 of Firefox that allow me to advance or go back more than one page

    You can also hold down the left button of the mouse on the active back or forward button until the list opens.

  • Adobe Acrobat standard version have have bar code? or only the version Pro is that the options?

    Hello

    I downloaded the trial version of adobe acrobat pro DC and I have all the options I need there.

    Now I'm done with the trial version and the need to buy, now I am confused whether to buy the standard or Pro version?

    Can someone help me by saying what options do not exist in the standard version which exist in the Pro version?

    You can add fields from the form, including a barcode field, in both versions. For a

    See comparison:

    https://Acrobat.Adobe.com/us/en/pricing/pricing-Compare-plans.html

  • A PDF of a website does not download even if a window opens, how to fix this?

    The Web site I can access is https://ebill.3rivers.net/siscss/pt/logonSubmitForward.do. I am able to get a PDF of the with IE and get a PDF of websites in Firefox, but not this one. I also have set Firefox to use its PDF Viewer. I use version 20.0.1 of Firefox.

    Well, Yes, that's the problem with this site. They were throwing you directly into the PDF document, Firefox would close the window. But instead, they launch a page that frames the PDF as well as another web page. In this case, Firefox does not close the window.

  • Downloaded and installed but still get a message to this update for Microsoft 2012 updated 4 Package redistributable Visual C++ (KB3119142)

    I downloaded and installed the update for Microsoft 2012 updated 4 Package redistributable Visual C++ (KB3119142) 6 times, but MS update that always shows a significant update. Is there somewhere I can download this and then install it manually? What should I do for this update recognized as installed in windows 8?

    Neha, thanks for the reply.

    I found this solution and it worked to prevent the download of appearing whenever I start my computer. This repair may not solve the problem but downloading this update again and again is only adding to the problem. Maybe Microsoft will offer a real solution soon.  I looked in my update history and you can see all the times that I downloaded this so I hope that this update is actually doing what he should do.

    Here is how I solved the problem (installation repeated 3119142 KB):

    1. go in Control Panel > programs > programs and features

    2 right-click "redistributable Microsoft Visual C++ 2012 (x 64) - 11.0.61030.

    3. Select 'Edit' and select 'Repair' and then after that repair is done restart the PC

    After the reboot, repeating installs is more took place.

    (Note: Although this solution solves the problem, the 'real' fix will likely run by Microsoft (via an update update) in the near future.)

  • How to prevent duplication of backup information? The same information is save several times (5 or more)

    I have the PC set to back upwards once a week and whenever it backs up the same information, files, images, and videos, etc. every time. Is there a way to avoid this and back up only the new information?

    Hi Dicin,

    Thanks for choosing Microsoft Community!

    If I understand correctly, you want to stop to save duplicated information.

    Please answer these questions:

    1. are you referring to back up and restore on Windows 7 feature?

    2 - is a system image backup or do you have what it takes to save?

    Ideally, backups are created in sets called backup periods. To maximize your disk space, Windows backup backup all folders selected the first time that he run and then it only backs up files that are new or have been modified since the last backup was made.

    Periodically, Windows creates a new, full of back up. Each full backup is called in a backup. When you view your backups of files, you can see all the backup periods with date ranges. If you decide to delete backups of files, you should always keep the most recent backup of the file.

    I suggest you read the following articles for more information:

    Back up and restore: frequently asked questions:

    http://Windows.Microsoft.com/en-us/Windows7/back-up-and-restore-frequently-asked-questions

    Back up your files:

    http://Windows.Microsoft.com/en-us/Windows7/back-up-your-files

    Hope the helps of information. Do not respond to help you further. We will be happy to help you.

  • CANNOT DOWNLOAD MY OWN PDFS IN EMAILS OR EVEN THOSE WHO SENT ME

    I'm a widow and I feel so lost today. I tried to download my own PDF there a small symbol on this circle with a red cross through. Says that you are allowed to download. It of frustrating, can anyone help? Michelle

    You are an administrator of your PC? Please post a screenshot of the icons.

    In addition, make sure you use a PDF reader:

    https://get.Adobe.com/reader/

  • Is it possible to display the index of the real estate code I created in the page html, css layout?

    Hi all!

    First of all, I'm really sorry if this is a bad question, but I found this option in other html tools (like PHP storm) and tried many options in CS6, without success.

    What I do: just started to learn html 5 with an online course (without a master, a few videos), so I'm really a user "rookie".

    I am working to put an image in html using css for formatting, so:


    1 - the index.html, I wrote the following code:

    < figure class = "foto-legenda" >

    < img src = "_imagens/image.jpg" >

    < figcaption >

    Test image < h3 > < / h3 >

    Legend of the Image Test < p > < /p >

    < / figcaption >

    < / figure >


    2. If, then, I need to define properties for "foto-legenda", in "file.css", like border etc, and what I've done:

    }

    {Figure.foto - legenda}

    border: 8px #F00 solid;

    }

    Far, so what it s works fine, but the question is:

    After I have written "< figure class ="foto-legenda...»" ', in html code, I want to write in css page, a bit of code and retrieve the indicator for the options that I started on the HTML page.

    For example, in css page, I'm starting to write 'figure'and get the hint of 'illustration' or 'figure class' (all from "figure"), after you selected the desired setting and start writing get «foto...» ", " foto-legenda " indicator.

    I hope it's clear.

    Thank you in advance.

    Sorry, it does not work like that.

    First of all, define the class of CSS selector.  Save your CSS file.

    .foto-legenda {border: 1px solid #CCC; padding: 0.5em}

    Now, when you type the class HTML = "foto... indicators of code will give you the class in a drop-down list.  See screenshot.

    As far as I KNOW, the code in DW CSS hints never picked up HTML classes.

    Nancy O.

  • Download a facility to update camera RAW 7.3 failed. How to solve this problem?

    Download and installation of update camera RAW 7.3 failed. How to solve this problem?

    If the download fails, try using another browser.

  • Decided to download Windows 95 for my Linux computer and I restarted and it says: enter the Startup Code!

    Computer fell because I downloaded Windows 95' soft '

    I decided to download Windows 95 for my Linux computer and I restarted and it said: enter the Startup Code!

    Hello
    a startup code? What type of boot disk that you use? Sounds like something from another program.
    Now don't get me wrong, I did not install Win 95 in about ten to twelve years, but I do not remember a start-up code!
    You can do a Bing search on installation of Windows 95 on Lynux for more information.
    Hope this helps,
    B Eddie

  • whenever I try to certify a document using my E-token brazilin, it appers: the windows cryptographic service provider reported an error. Code: 2148073510. Someone knows how to fix this?

    I would be grateful if someone could help me. Every time I try to certify a document using my E-token brazilin, it appears: the windows cryptographic service provider reported an error. Code: 2148073510. Someone knows how to fix this?

    Problem of this sort occurs generally when the driver that supports your token is not fully compliant with all standards. Some signature applications are mild for some of the discrepancy and you can still use your signature token in these applications. Acrobat is more strict about this.

    Without actually having your token, it is difficult to continue the investigation.

  • Adobe Photo Downloader has encountered a problem and needs to close. We are sorry for the inconvenience.  Error code: c0000005 address: 76f73ac3 I clicked the OK button and the closed Downloader.     I then tried to download from the Organizer. I have

    Photoshop Elements 12

    Adobe Photo Downloader has encountered a problem and needs to close. We are sorry for the inconvenience.

    Error code: c0000005

    Address: 75e32f71

    I clicked on the OK button and the closed Downloader.

    I did a search on this (c0000005) error code and it seems to be a work around, but no solutions, why is this? I ask that because that this problem seems to be years and years, dating back to at least 2005 (math is 10 years do).

    I don't even have the hanging camera and I get this error on download.  I have redownloaded everything and reinstalled.  I allso see AVI issues reported with this problem, so I've updated Quicktime that without the camera being hung when I get this error I wasn't expecting it to work.  I tried to support and they would not help because I bought it in March this year.  Quite frustrating because I bought elements about every 2 years.  I think I might need a new codec?   I had this problem on an earlier version and I think I remember that being the fix, but it may be something completely different

    Finally, I found it lacking a photo so the catalogue was "corrupted".  I just deleted the image and it started working.

    I hate Adobe and their total lack of support - thanks for nothing Adobe.  Also get this - they offered me to upgrade to 13.0 (12.0 My is only 6 months old but they still can't stand on errors.  Install only the errors!

    I've upgraded and buy this product 4 times now.  I'll find something else next time!

Maybe you are looking for

  • When do you think will stop the iPad 2 air?

    Maybe it's a weird question, but I really need answers. I need to buy a smart case for my iPad after a year or two, 2 Air iPad looks already like 2 years. And I fear that one day I'm going to the Apple Store, they no longer sell smart case for my iPa

  • Why upgrade

    Hi all This old wonders of 91: I don't have an iPhone, I do not use masses of apps, so what advantage is there to El Capitan of Maverick, which works very well with things like Adobe CS6, Blurb.com and Skype?

  • Skype for windows xp sp3 64/32 bit

    Why can't this thing work on windows xp. What I get from trying to download it is code 1603. Can I get help on this pls. Ty

  • ReadFile for expressions of folklore

    I use the function ReadFile read in ASCII mode. ReadFile account CR + LF as a LF.The byteRead are always less than the size of the file that is obtained with the help of GetFileInfo(). The read data is so not until the end of the file.The loop in thi

  • Cannot install ANY video game on Windows 7 (and other problems) _

    No more than 5 MINUTES after starting my new desktop computer the first time, I started having these problems: (1) when I try to install a game, I get an error message that says "cannot continue the installation. SAMPLE.exe file missing. "Soon after,