Link to home
Start Free TrialLog in
Avatar of suprapto45
suprapto45Flag for Singapore

asked on

Servlet Redirect Question

Hi,

Will the "request" be included?

1st scenario
request.setAttribute("time_arrive_dynamic", dynamic_time_arrive);
request.getRequestDispatcher("/jsp/planning/flightsearchonly.jsp").forward(request, response);

2nd scenario
request.setAttribute("time_arrive_dynamic", dynamic_time_arrive);
response.sendRedirect("https://" + request.getServerName() + "/flightsearch.jsp");

regards
Dave
Avatar of suprapto45
suprapto45
Flag of Singapore image

ASKER

Hi,

I mean can we access the request.getAttribute("time_arrive_dynamic") in the flightsearch.jsp and in flightsearchonly.jsp in both scenarios?

Regards
Dave
ASKER CERTIFIED SOLUTION
Avatar of cincin77
cincin77

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick Barry
Thats right, a redirect causes the browser to make a new request, whereas a forward is handled internally.
Hi,

Thanks. Sorry objects but I will accept cincin77 answer since he is the first to answer. I am sorry. Thanks cincin77 :)

Thus, what is the use of redirect? it seems useless, right?
Thats fine :)

You can only forward relative to the webapp making the call, otherwise you need to redirect.
redirects will also update the address in the browser (as the browser makes the request to the new url)
Avatar of cincin77
cincin77

So redirect is not useless.:)
thanks for the points.