How to get uploaded file name?

I'm trying to make upload with Jersey multipart. Everything working well. But I cannot get uploaded filename. I think it's library problem.

Here is dependencies from my pom.xml


My UpploadFileService

public class UploadFileService {

    public Response uploadFile(
            @FormDataParam("file") InputStream uploadedInputStream,
            @FormDataParam("file1") FormDataContentDisposition fileDetail) {

If I change @FormDataParam("file1") to @FormDataParam("file") POST request will return Bad Request. But it's working well without it.

How can I get filename? And why @FormDataParam("file") makes service return Bad Request?


My html for uploading

<h1>File Upload with Jersey</h1>

<form action="http://localhost:8080/Project/api/file/upload" method="post" enctype="multipart/form-data">

    Select a file : <input type="file" name="file" size="45" />

  <input type="submit" value="Upload It" />



public class Application extends {
    public Set<Class<?>> getClasses() {
        final Set<Class<?>> resources = new HashSet<>();
        return resources;


You can get the uploaded file name using String fileName = fileDetail.getFileName();

Jersey 1 uses com.sun package and Jersey 2 uses org.glassfish package. Never mix them. Replace your


With this one:


Need Your Help

Do Something When Window Loads

javascript window onload

I am trying to open an alert box when a window loads. Here is what I have:

Adding javascript validation to existing acroform field in pdf with iText

java itext

I am trying to add javascript validation to an existing Acroform field via iText in java. I have written the following code so far, but no action is assigned to the form field. Is there something I...