ASF Bugzilla – Attachment 36123 Details for
Bug 62664
@MultipartConfig, getParts(), and getParameter() on PUT requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
HttpServlet subclass which will echo parameters for POST and for PUT before and after calling getParts()
EchoParamsServlet.java (text/plain), 1.68 KB, created by
Robert Tupelo-Schneck
on 2018-08-30 19:21:36 UTC
(
hide
)
Description:
HttpServlet subclass which will echo parameters for POST and for PUT before and after calling getParts()
Filename:
MIME Type:
Creator:
Robert Tupelo-Schneck
Created:
2018-08-30 19:21:36 UTC
Size:
1.68 KB
patch
obsolete
>import java.io.IOException; >import java.util.Map; > >import javax.servlet.ServletException; >import javax.servlet.annotation.MultipartConfig; >import javax.servlet.annotation.WebServlet; >import javax.servlet.http.HttpServlet; >import javax.servlet.http.HttpServletRequest; >import javax.servlet.http.HttpServletResponse; > >// compare: >// curl -i -X POST 'http://localhost:8080/echo-params/' -F a=b >// curl -i -X PUT 'http://localhost:8080/echo-params/' -F a=b >// curl -i -X PUT 'http://localhost:8080/echo-params/parts-first' -F a=b > >@WebServlet("/*") >@MultipartConfig >public class EchoParamsServlet extends HttpServlet { > private void showAllParams(HttpServletRequest req, HttpServletResponse resp) throws IOException { > for (Map.Entry<String, String[]> entry : req.getParameterMap().entrySet()) { > String key = entry.getKey(); > for (String value : entry.getValue()) { > resp.getWriter().println(key + "=" + value); > } > } > } > > @Override > protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { > showAllParams(req, resp); > } > > @Override > protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { > if (!"/parts-first".equals(req.getPathInfo())) { > resp.getWriter().println("before getParts:"); > showAllParams(req, resp); > resp.getWriter().println(); > } > try { > req.getParts(); > } catch (Exception e) { > e.printStackTrace(resp.getWriter()); > } > resp.getWriter().println("after getParts:"); > showAllParams(req, resp); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 62664
: 36123