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.

redirectとforwardについて

Posted at

プログラミング初学者です。
JSP,Servletで処理ページを別ページに移す方法として学んだことをアウトプットします。

Q: redirectとforwardは何が違う?

A: 変移するまでの過程が違う

redirect
  ↓
①クライアントからサーバーにページAを表示するリクエスト。
②サーバーからクライアントにページAからページBに変移するよう指示する。
③クライアントからサーバーにページBに変移するようリダイレクト指示
④サーバーからページBの結果が送られてくる

forward
  ↓
①クライアントからサーバーにページAを要求
②サーバー側で自動でページBに処理を写しクライアントに結果をおくる。

基本的にforwardの方が良い!

なぜなら、、、
・リクエスト情報を引き継げる
・redirectよりパフォーマンスが良い etc....

redirectを使うタイミング

・外部のサーバーにアクセスする際

【参照元】
https://www.atmarkit.co.jp/ait/articles/0407/06/news077.html

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?