1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

学習メモ01(forward/redirect)

Last updated at Posted at 2019-03-24

【servlet/JSP】forwardとredirect

どちらも、servletからJSPにページ遷移をするために使う命令文。
細かいところで挙動が違うらしい。(実務経験0なので実感が沸かんw)

forward

RequestDispatcher rd = request.getRequestDispatcher("test01.jsp");
rd.forward(request, response);

--------------------
・javax.servlet.RequestDispatcherをインポートする必要あり
・リクエストスコープを使って値をservlet→JSPに受け渡しできる
--------------------

redirect

//リダイレクト
response.sendRedirect("test02.jsp");

--------------------
・URLが書き換わる
・リクエストスコープを使って値をサーブレット→JSPに受け渡しできない
--------------------

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?