在servlet中,利用out输出对象,输出到浏览器端一段js代码。实现页面的跳转或者弹出框的提示
实例:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {response.setContentType("text/html");
PrintWriter out = response.getWriter(); /*String content = "window.location.href='index.jsp'";*/ String content = "alert('123');"; out.println("<script language=\"javascript\">" + content + "</script>"); out.flush(); out.close(); }