Servlet sendRedirect

J

James

Hi,

I have an issue related to servlets.

When i process a servlet in some instances a request is made to use
sendRedirect(). This works correctly however the remaining process on
the existing servlet is carried out.

Servlet1 is run
Servlet1 redirects to Servlet2
Servlet1 continues to run until end

Is thier any way, other than putting conditional tests into parts of the
code to ensure that servlet1 ends when servlet2 is called?

Im currently using the following code to indicate a forward:

*resp is the Response object*

resp.resetBuffer();
resp.setStatus(302);
resp.sendRedirect(url);

this.forwardingstate = true;

The two problems with what is happening is that processing any
additional code is a waste of resource and sometimes both the original
and redirected page both appear on the same browser window.

Any help of this would be really appreciated.

Thanks,
James.
 
N

Neill

James said:
Hi,

I have an issue related to servlets.

When i process a servlet in some instances a request is made to use
sendRedirect(). This works correctly however the remaining process on
the existing servlet is carried out.

a return statement to exit the service method, doGet() or doPost() should do
it. - Neill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top