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 8285389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:27:26+00:00 2026-06-08T11:27:26+00:00

Just like title, I want to ask, how to adding pdf files with upload

  • 0

Just like title, I want to ask, how to adding pdf files with upload form to my storage folder (e.g: uploadData) then its added to database as a file too in JSP.

If it not possible, it’s ok to added to database as a text.

If it possible as a file, what type of my table for that pdf? blob? or text?

I accept blog links/other links that relevant for my problem

sorry for bad english.

  • 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-08T11:27:27+00:00Added an answer on June 8, 2026 at 11:27 am

    Servlet 3.0 container’s has standard support for multipart data. It also has the support to write to local file system. First you should be writing a HTML page which takes the file input along with other input parameters.

    <form action="uploadservlet" method="post" enctype="multipart/form-data">
        <input type="text" name="name" />
        <input type="text" name="age" />
        <input type="file" name="photo" />
        <input type="submit" />
    </form>
    

    Now write a UploadServlet which uses the Servlet 3.0 Upload API. Here is the code which demonstrates the usage of API. Fist the servlet handling multipart data should define MultiPartConfig using any of the two approaches:

    • @MultiPartConfig annotation on Servlet Class
    • In web.xml, by adding entry inside definition.

    Here is the UploadServlet,

    @MultipartConfig
    public class UploadServlet extends HttpServlet
    {
      protected void service(HttpServletRequest request, 
       HttpServletResponse responst) throws ServletException, IOException
      {
      Collection<Part> parts = request.getParts();
      if (parts.size() != 3) {
         //can write error page saying all details are not entered
       }
    
       Part filePart = httpServletRequest.getPart("photo");
       InputStream imageInputStream = filePart.getInputStream();
       //read imageInputStream
       filePart.write("somefiepath");
       //can also write the photo to local storage
    
       //Read Name, String Type 
       Part namePart = request.getPart("name");
       if(namePart.getSize() > 20){
           //write name cannot exceed 20 chars
       }
       //use nameInputStream if required        
       InputStream nameInputStream = namePart.getInputStream();
       //name , String type can also obtained using Request parameter 
       String nameParameter = request.getParameter("name");
    
       //Similialrly can read age properties
       Part agePart = request.getPart("age");
       int ageParameter = Integer.parseInt(request.getParameter("age"));
    
    
    
    }
    
    }
    

    If you are not using Sevlet 3.0 Container, you should be truing Apache Commons File Upload. Here are the links for using Apache Commons File Upload:

    • Using Apache Commons File Upload
    • Apache Commons File Upload Example

    References:

    • File Upload Using Servlet 3.0
    • Servlet 3.0 javax.servlet.http.HttpServletRequest API
    • Servlet 3.0 javax.servlet.http.Part API
    • Uploading File using Servlet 3.0
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just like the title says; I want to use something like Mid( stringName ,
Just like the title ,when I touch the UIView I want the touch point
Just like in the title; I have a remote server and I want to
So, just like the title says, I need to create an application that gets
Just like in the title. I got GridView control that displaying some data from
As in title users Just can't get the like button to work properly on
Just like in topic I try to create a form when the elements create
As the question's title says, I want to get the system information (like OS
Just like the title says. Because buildin widgets do not really fit, what I
Just like the title said. For example: I have a class like this: class

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.