[Java]sendRedirectリダイレクトのサンプル
書式
response.sendRedirect(xxx)
使用例
public class ResponseDemo extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{ response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); String md; String adr = ""; md = request.getParameter("url"); if (md == null || md.length() == 0){ adr = "xxxx"; }else{ adr = "http://" + md; } response.sendRedirect(adr); } }