Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2005, 12:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rushman
Default jsp:forward problem

Taken from http://www.jspinsider.com/content/js...le_Redirection

 
Quote:
quote:The forward action ends execution of the current JSP page and removes any existing buffered output. The new page has access to following objects (Application, Request, Session) as the starting file. A new pageContext object is generated for the page. To the browser it will appear you have the originally requested page not the page to which you are transferred.
Quote:

- You can forward to a text file(HTML), a CGI script, a servlet or another JSP page.
- You can only forward to a new page provided no output of the original page has been sent to the browser.
My question is: WHAT IF some output has been sent to the browser?

How can I forward/redirect to another JSP without causing the output stream to close?

I know that I can output a script with window.location.href = 'myPage.jsp'. The problem is that I possibly post lots of parameters to the destination page. I can't use myPage.jsp?param=blabla&param=blibli&param=... because sometimes I will go beyond the browser's maximum URL length .

Any help will be greatly appreciated,

RushMan


Dijkstra's law on Programming and Inertia:

If you don't know what your program is supposed to do, don't try to write it.
__________________
Dijkstra's law on Programming and Inertia:

If you don't know what your program is supposed to do, don't try to write it.
 
Old October 24th, 2005, 10:36 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How can I forward/redirect to another JSP without causing the output stream to close?

If you are talking about output to the browser then I dont think you can, when you redirect your code will ignore output, even if it is encountered before the redirect statement.

Server side stuff will sill be completed though, which is something you need to watch out for if you are using re-direct to return someone to the login screen if they do not have access.

In this instance you would add a return; statement directly after the response.sendRedirect(); in order to kill the process.

I discovered this when I noticed database records were still being updated after the redirect statement.

So, in short, you will continue to execute stuff on the server, but not in the browser, I think!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Forward after Login ~Bean~ ASP.NET 1.0 and 1.1 Basics 1 July 14th, 2005 05:14 PM
question about RequestDispatcher forward allang JSP Basics 2 June 28th, 2005 06:39 PM
Forward booking rahilahmed Pro VB Databases 1 June 16th, 2004 06:02 PM
Forward Booking rahilahmed Excel VBA 0 May 24th, 2004 09:25 AM
jsp:forward equivalent lpongan Beginning PHP 6 May 19th, 2004 07:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.