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

  • SEARCH
  • Home
  • 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 7434287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:48:40+00:00 2026-05-29T09:48:40+00:00

I am developing an web application which can upload/download a file from client to

  • 0

I am developing an web application which can upload/download a file from client to PostgreSQL database server via GWT RPC call.

I managed to create an upload servlet which store desired file(choosed by user via FileUpload widget) to Glassfish “TEMP” directory => then i used SQL command:

INSERT INTO table VALUES ('"+name+"',lo_import('"+f.getCanonicalPath()+"\\TEMP\\"+name+"'),...) 

which put that file into database. This works pretty good.

Problem occurs when i want to download file from server to client. First i need to put the file back to TEMP dir with SQL command lo_export(…) -> this didn’t work (some ERROR when creating a server file, permission denied), so i put the file manually to TEMP dir.

Question is how can i display that file which is stored on server in TEMP dir?

  • my path to glassfish server temp dir:C:\Program Files (x86)\glassfish-3.1\glassfish\domains\domain1\TEMP\example.pdf
  • when deploying app url looks like: http://localhost:8080/AppName/
  • i tried something like that: Window.open(“http://localhost:8080/AppName/TEMP/example.pdf”, “_blank”, “enabled”)

My CODE:
Client side:

String link = GWT.getModuleBaseURL() + "filedownloadservlet";
Window.open(link,event.getSelectedItem().getText(),"enabled");

so i pass to servlet located on server side a link and a file name…am i right ?

Server side:

public class FileDownloadServlet extends HttpServlet {
    private String path = "TEMP//"; // Your absolute path
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {             

    String filename = req.getParameter("filename");
    System.out.println(filename); // THIS IS NULL value

    File userManualFile = new File(path + filename);
    // You can fetch a Blob from the database instead.

    ServletOutputStream servletOutputStream = resp.getOutputStream();
    resp.setContentType("application/pdf");
    resp.addHeader("content-disposition", "attachment; filename=skuska.pdf");

    FileInputStream fileInputStream = new FileInputStream(userManualFile);

    IOUtils.copy(fileInputStream, servletOutputStream);
    servletOutputStream.flush();

When i press a file in Tree widget it shows me a new browser window with this error:

java.io.FileNotFoundException: TEMP\null (The system cannot find the file specified)
  • 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-05-29T09:48:41+00:00Added an answer on May 29, 2026 at 9:48 am

    You cannot download a file with a RPC call. You must use a normal java servlet. You have to write the bytes into the HttpServletResponse. You can get the bytes from the file in the database by doing an SQL query.

    This example is done with spring MVC.

    @Controller
    public class UserManualServlet {
    
      private String path = "..." // Your absolute path
    
      @RequestMapping("/app/usermanual.download")
      public void generateInterceptActivationDeactivationReport(HttpServletRequest request, HttpServletResponse response)
        throws IOException
      {
    
        String filename = request.getParameter("filename");
    
        File userManualFile = new File(path + filename);
        // You can fetch a Blob from the database instead.
    
        ServletOutputStream servletOutputStream = response.getOutputStream();
        response.setContentType("application/pdf");
        response.addHeader("content-disposition", "attachment; filename=\"user-manual.pdf\"");
    
        FileInputStream fileInputStream = new FileInputStream(userManualFile);
    
        IOUtils.copy(fileInputStream, servletOutputStream);
        servletOutputStream.flush();
    }
    

    In this example, you can call the URL : ../app/usermanual.download?filename=usermanual.pdf to download the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing a mobile web application which user's can reach via their mobile
I am planning on developing .NET web application which also will be accessed from
We're developing a web application which uses EJB to connect to a database. In
I was developing an application which can receive a url of a file, and
I'm developing a web application in which users are allowed to upload pictures, the
I'm developing an ASP.Net web application which makes use of MySQL via the MySQL-Provided
I am currently developing an Android application which has a web backend. I can
I'm developing a real-time web application which sends AJAX requests to the server every
I am developing a web application which has Chart Controls. I have developed a
We are developing a web application which is available in 3 languages. There are

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.