Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See POST parameters in Java EE eclipse debugging

I'm not experienced in debugging Java EE (I'm rather a javascript guy) and I need to see what HTTP POST parameters get to the server side. I put a breakpoint in a jsp file that the form is pointing its action to and now I can't find the POST content in the debug variables window.

Where are they? How can I lookup the POST in debug?

[I'd use wireshark, but it's over the https]

like image 545
naugtur Avatar asked Sep 04 '26 11:09

naugtur


2 Answers

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

<%
   if (request.getMethod().equals("POST")) {
      for (String paramName : request.getParameterNames ()) {
          String value = request.getParameter (paramName);
      }
   }
%>
like image 172
John Doe Avatar answered Sep 07 '26 00:09

John Doe


In the breakpoint, just check the HttpServletRequest property of the JspContext instance and then check its parameterMap property.

Or do it the poor man's way by just 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>

That said, you'd normally be interested in them inside a servlet class, not inside a JSP. This would indicate that you're doing some business logic inside a JSP file using using scriptlets. This is considered bad practice. Don't do that and move that raw Java code to real Java classes before it's too late. Use JSP for presentation only. You can use taglibs like JSTL to control the page flow and use EL to access backend data.

like image 43
BalusC Avatar answered Sep 07 '26 00:09

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!