[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Servlet Redirect Question

Posted on 2005-05-12
6
Medium Priority
?
540 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:suprapto45
  • 2
  • 2
  • 2
6 Comments
 
LVL 16

Author Comment

by:suprapto45
ID: 13984208
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
0
 
LVL 3

Accepted Solution

by:
cincin77 earned 600 total points
ID: 13984286
in the first case YES.
in the second case NO.

In the second case, you finish the request-response cycle and tell the browser to get another page.("https://" + request.getServerName() + "/flightsearch.jsp") Then the browser makes a new request, and the container creates a new request-response pair for your servlet or jsp.

hope this helps.
0
 
LVL 92

Expert Comment

by:objects
ID: 13984407
Thats right, a redirect causes the browser to make a new request, whereas a forward is handled internally.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 16

Author Comment

by:suprapto45
ID: 13984450
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?
0
 
LVL 92

Expert Comment

by:objects
ID: 13984469
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)
0
 
LVL 3

Expert Comment

by:cincin77
ID: 13985337
So redirect is not useless.:)
thanks for the points.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month18 days, 19 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question