3

I am developing a web service using jersey and Maven. I want to pass a file path via Url to send the it to server. But i got an error as: enter image description here

in web server:

@Path("/hello") //Path
public class HelloWorldService {
@GET
    @Path("/{param}") //parameter
    public Response getMsg(@PathParam("param") String msg) throws MalformedURLException, ClassNotFoundException, IllegalArgumentException, FileNotFoundException, FileFormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, SecurityException {

        String output ="Server response: "+  msg; //Get the file path here.
        return Response.status(200).entity(output).build();

    }
}

How to i can pass the path to server?

MyNguyen
  • 319
  • 4
  • 14
  • need to encode the URL param. If you are using javascript to send the request then take a look at `encodeURI()` – sidgate Oct 30 '15 at 09:11

2 Answers2

1

Check the following question then...

...encode path with base 64 on the client side and decode it on the server

Let's say You have 'C:\path\to\your\file.jar' path

Encode it with base 64: QzpccGF0aFx0b1x5b3VyXGZpbGUuamFy

Then send the following request to the server:

localhost:8080/files/QzpccGF0aFx0b1x5b3VyXGZpbGUuamFy

Dawid Dyrcz
  • 355
  • 1
  • 4
  • 10
0

you should not be passing the file path as an request parameter , because it will not parse properly / character. On click on "send to server button" you can repalce / by some other character like # and at server side you can parse again.