alert And Redirect History via HttpServletResponse - Java javax.servlet.http

Java examples for javax.servlet.http:HttpServletResponse

Description

alert And Redirect History via HttpServletResponse

Demo Code


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;

public class Main{
    public static void alertAndRedirectHistory(
            HttpServletResponse response, String alert) throws IOException {
        response.setContentType("text/html; charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println("<script>");
        out.println("alert('" + alert + "');");
        out.println("history.go(-1);");
        out.println("</script>");
    }//from  w  w  w . ja v a 2 s.  c  o  m
}

Related Tutorials