2
votes

I'm developing a simple WebServer with Java (Using org.apache.http.HttpRequest and org.apache.http.HttpResponse).

I have an HTML page like this:

<form action="/upload" enctype="multipart/form-data" method="post">
  <label for="datafile1">First File:</label>
   <input type="file" id="datafile1" name="datafile1" size="40"><br>
  <input type="submit">
</form>

On the Java Server i get the POST request, read the Multipart content and fill up an HttpEntity as Response but the page loaded is (obviously) "/upload"

How can I tell the browser that the response url is something else?

I have tried:

response.setHeader("Location","/");

But with HTTP Status code 200 nothing happened And with HTTP Status code 302 the browser make a new request, deleting the one I have returned.

Any ideas?

2
The form action is set to "/upload" so browser load page with url "/upload" and my content but I want to change the url to "/" without making a new request-response (that will change the content) - TheZero

2 Answers

0
votes

you should send it with a 3XX status code usualy 302.

0
votes

Finally I have done it with 2 response object and returned one with "Location" and status 302.

Thanks!