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]
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);
}
}
%>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With