Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:45:44+00:00 2026-06-07T12:45:44+00:00

I have JBoss running as application server and somewhere on my HD there is

  • 0

I have JBoss running as application server and somewhere on my HD there is a PDF file, that gets created when the user clicks on a specific action. Let’s say the file is here: C:/PDF/doonot/10.07.2012/doonot.pdf. How can I offer this file as download? I already did it for a CSV file, but I don’t know how to do it with PDF.

Any help is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:45:47+00:00Added an answer on June 7, 2026 at 12:45 pm

    as i wrote on Is there a common way to download all types of files in jsp?

    you can use something like this:

    public HttpServletResponse getFile (HttpServletRequest request ,HttpServletResponse httpServletResponse, .......){
              HttpServletResponse response = httpServletResponse;
              InputStream in =/*HERE YOU READ YOUR FILE AS BinaryStream*/
    
              String filename = "";
              String agent = request.getHeader("USER-AGENT");
              if (agent != null && agent.indexOf("MSIE") != -1)
              {
                filename = URLEncoder.encode(/*THIS IS THE FILENAME SHOWN TO THE USER*/, "UTF8");
                response.setContentType("application/x-download");
                response.setHeader("Content-Disposition","attachment;filename=" + filename);
              }
              else if ( agent != null && agent.indexOf("Mozilla") != -1)
              {
                response.setCharacterEncoding("UTF-8");
                filename = MimeUtility.encodeText(/*THIS IS THE FILENAME SHOWN TO THE USER*/, "UTF8", "B");
                response.setContentType("application/force-download");
                response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
              }
    
    
              BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
              byte by[] = new byte[32768];
              int index = in.read(by, 0, 32768);
              while (index != -1) {
                  out.write(by, 0, index);
                  index = in.read(by, 0, 32768);
              }
              out.flush();
    
              return response;
    }
    

    UPDATE:

    Dont forget that you can use the InputStream as this:

    // read local file into InputStream
    InputStream inputStream = new FileInputStream("c:\\SOMEFILE.xml");
    

    or you can use it even like this

    //read from database
    Blob blob = rs.getBlob(1);
    InputStream in = blob.getBinaryStream();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application running in a jboss application server (But it is
I have a web application deployed on a jboss server running on a unix
I have jboss server running with fr_CH locale and application client running with de_CH
I have an application server (JBoss, but this also happens in Tomcat) running as
I have Axis2 web services running in an Application Server (like JBoss, WebSphere and
I have an application running on a JBoss server. We need update the application
I have an application running in JBoss AS6. Authentication is working using the FORM
I have an Java application running in JBoss in which I have enabled JMX
I have the css-validator.war file provided by W3C running locally on JBoss . I
I have a java web application (running on JBoss), which need to authorizate users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.