i am having this problem where i have retrieved a value using the post method and i want to print that value how do i do that?
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String comment = request.getParameter("comment");
PrintWriter out = response.getWriter();
int id = Integer.parseInt(request.getParameter("qid"));
out.print(+id+);
}
/**
* Returns a short description of the servlet.
*
You can use ServletOutputStream with print() method. Another possibility is to use PrintWriter .
response.getWriter().print(variableToPrint);
Usually, you can do something like that,
String json = "<some_JSON>";
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(json);
, and you will see your response printed in the log console.
In the same way, you can write your value instead of a JSON.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.