-1

I want to redirect for mystart.java servlet to two servlet edit.java and upload.java I’m using get method for mystart.java and get method for edit.java which works fine but upload.java isn’t working because I’m using post method so I get 405 error Get method not supported by this URL.

Response.sendRedirect(“upload”)
Jens
  • 67,715
  • 15
  • 98
  • 113
Gidde
  • 1
  • 4

1 Answers1

1

You cannot. A redirect is a way to tell the browser to use a different URL for the current request. The browser will then retry the same request with the new URL.

According to https://httpwg.org/specs/rfc9110.html#status.302 some browsers might in the process change the request from POST to GET:

Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request.

However this entirely depends upon the user agent (browser) and it is not something that your servlet can request.

Also there is no way that a redirect can tell the browser to use a POST instead of a GET.

Thomas Kläger
  • 17,754
  • 3
  • 23
  • 34