You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by karthi <ra...@snovabits.net> on 2012/06/27 12:46:08 UTC

How to resolve: getWriter() has already been called for this response

Hi,

I have a page and inside that page's onActivate method called like below

servletResponse.sendRedirect("link");

it redirects that link successfully when the page comes but it also throws
the below error in logger file

[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed
with uncaught exception: getWriter() has already been called for this
response 
java.lang.IllegalStateException: getWriter() has already been called for
this response 

What is wrong here? how can I resolve this?

Regards,
Karthi.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-resolve-getWriter-has-already-been-called-for-this-response-tp5714111.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: How to resolve: getWriter() has already been called for this response

Posted by karthi <ra...@snovabits.net>.
I misunderstood previously, it works now. Thanks.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-resolve-getWriter-has-already-been-called-for-this-response-tp5714111p5714132.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: How to resolve: getWriter() has already been called for this response

Posted by "Poder, Jacob" <ja...@thermofisher.com>.
Try this:

Object onActivate() {
     
     String domain = request.getHeader("Host");
     if(null != domain) {
		if(!domain.contains("webapp.m.sample")) {
			try {
				return new URL("http://webapp.m.sample/Registration/portfolio");
			} catch (final IOException e) {
				logger.error("Exception: " + e);
			}
		}
	}
	return null;
}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to resolve: getWriter() has already been called for this response

Posted by karthi <ra...@snovabits.net>.
My issue is:

Whenever a button click is happened in my tapestry page the address bar
changed like below:

For E.g.,

http://webapp.m.sample/Registration/login             

---> After clicked on the login button address bar value changed to

http://174.58.25.24/Registration/portfolio

Login happens successfully and my page navigated to the success page (here
portfolio) but the only problem is domain name changed to IP address in the
address bar

This is a routing issue and need to be fixed by network admin, however I was
asked to give a workaround for this issue through application so tried the
below logic:

In the onActivate method, checked the value of header HOST and if it is an
IP address then redirect to domain address with the response page 

void onActivate() {
     
     String domain = request.getHeader("Host");
     if(null != domain) {
			if(!domain.contains("webapp.m.sample")) {
				try {
					response.sendRedirect("http://webapp.m.sample/Registration/portfolio");
				} catch (final IOException e) {
					logger.error("Exception: " + e);
				}
			}
		}
}

This works cool in UI but in the background it throws the above mentioned
error 

[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed
with uncaught exception: getWriter() has already been called for this
response
java.lang.IllegalStateException: getWriter() has already been called for
this response

For this scenario please give me a suggestion to resolve this?

Thanks, 
Karthi.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-resolve-getWriter-has-already-been-called-for-this-response-tp5714111p5714130.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to resolve: getWriter() has already been called for this response

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 27 Jun 2012 10:15:23 -0300, karthi <ra...@snovabits.net>  
wrote:

> However the page gets re-directed successfully also am using a given API  
> only

Yes, but you're still doing something that shouldn't be done. Do the right  
thing and nothing will go to your log.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to resolve: getWriter() has already been called for this response

Posted by karthi <ra...@snovabits.net>.
However the page gets re-directed successfully also am using a given API only

org.apache.tapestry5.services.Response response;

response.sendRedirect("");


Can you please tell me how to turn off this log?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-resolve-getWriter-has-already-been-called-for-this-response-tp5714111p5714114.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to resolve: getWriter() has already been called for this response

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 27 Jun 2012 07:46:08 -0300, karthi <ra...@snovabits.net>  
wrote:

> Hi,

Hi!

> I have a page and inside that page's onActivate method called like below
> servletResponse.sendRedirect("link");

You're using the wrong way of doing redirects in Tapestry event handler  
methods. Instead, you should return a Link or java.net.URL instance.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org