Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes location bar of the browser on include/forward/sendRedirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "location bar of the browser on include/forward/sendRedirect" Watch "location bar of the browser on include/forward/sendRedirect" New topic
Author

location bar of the browser on include/forward/sendRedirect

Mala R
Greenhorn

Joined: Feb 18, 2003
Posts: 3
Hi,
I've a file1.jsp which is as follows :
<html>
<head>
</head>
<body>
<%= "In FILE1.jsp " %>
<jsp:forward page="file2.jsp" />
</body>
</html>
file2.jsp
----------
<html>
<head>
</head>
<body>
<%= "In FILE2.jsp " %>
</body>
</html>
When accessing file1.jsp in Tomcat as http://localhost:8080/file1.jsp
I get the o/p as "In FILE2.jsp".
The location bar in the browser is the same. i.e http://localhost:8080/file1.jsp
When I replace the <jsp:forward> with
<jsp:include page="file2.jsp" flush="true"/>
still I get the same result and the location bar also reads file1.jsp.
Same is the case with "response.sendRedirect("file2.jsp");
But when I was taking some mock up test,it gave explanation as when response.sendRedirect is used, location bar of the browser would display file2.jsp.
Pls clarify on whne the address bar will display file2.jsp.
Thanks.
Tom Adams
Ranch Hand

Joined: Feb 07, 2003
Posts: 56
Right - when you sendRedirect it updates the Address line in the browser. This is the way your example works for me....
Make sure in your test that you are not seeing a browser cached version of the page.


Tom
 
GeeCON Prague 2014
 
subject: location bar of the browser on include/forward/sendRedirect