See POST Options in Java EE eclipse Debugging

I do not experience Java EE debugging (I'm more of a javascript guy), and I need to see what HTTP POST parameters get to the server. I set a breakpoint in the jsp file, which the form indicates its action, and now I can not find the contents of the POST in the debug variables window.

Where are they? How can I find POST in debugging?

[I would use wirehark, but it's on https]

+2
source share
3 answers

At the breakpoint, simply check the HttpServletRequest property of the JspContext instance, and then check its parameterMap property.

Or make it a poor person by simply printing them all in the JSP:

 <c:forEach items="${param}" var="p"> Param: ${p.key}= <c:forEach items="${p.value}" var="v" varStatus="loop"> ${v}${loop.last ? '<br>' : ','} </c:forEach> </c:forEach> 

However, you are usually interested in them inside the servlet class, and not inside the JSP. This would mean that you are doing some kind of business logic inside a JSP file using scriptlets. This is considered bad practice. Do not do this and move this raw Java code to real Java classes until it is too late. Use JSP for presentation only. You can use taglib, such as JSTL, to control the flow of pages and use EL to access data on the server.

+3
source

In jsp, you can use the request object and call its getParameterNames () or getParameter (String name) method. You can also call request.getMethod () to get the parameters from the POST request.

 <% if (request.getMethod().equals("POST")) { for (String paramName : request.getParameterNames ()) { String value = request.getParameter (paramName); } } %> 
+4
source

In debug mode: see request β†’ request β†’ coyoteRequest β†’ parameters β†’ paramHashValues

+1
source

Source: https://habr.com/ru/post/1210709/


All Articles