如何响应JSP Servlet请求的自定义字符串
我需要的是不要重定向到doPost末尾的另一个JSP页面。我有一个字符串平面文本,我需要响应它作为Servlet请求。我该怎么做如何响应JSP Servlet请求的自定义字符串,jsp,servlets,Jsp,Servlets,我需要的是不要重定向到doPost末尾的另一个JSP页面。我有一个字符串平面文本,我需要响应它作为Servlet请求。我该怎么做 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { .... .... getServletContext().getRequestDispatcher("/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
....
....
getServletContext().getRequestDispatcher("/output.jsp").forward(request, response);
}
可以从中找到更多信息
可以从中找到更多信息您可以这样做:
//getServletContext().getRequestDispatcher("/message.jsp").forward(request, response);
response.getWriter().println(output); // output is the custom string
您可以这样做:
//getServletContext().getRequestDispatcher("/message.jsp").forward(request, response);
response.getWriter().println(output); // output is the custom string