You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael Mehrle <mi...@ask.com> on 2008/03/28 22:16:12 UTC

Writing directly to the HTTP Response object?

I have a non-Wicket AJAX request call a Wicket page to process some data
(it's that jQuery file uploader I was working on). Now, the PHP example
that came with that jQuery based file uploader writes out some status
information to the AJAX JS script via HTTP Response like this (I'm no
PHP coder):

{ echo "{";
Echo "error: ': . $error . "',\n";
Echo "msg: '" . $msg . "'\n";
Echo "}"

That's the message that the JS will use to show the status. Now, since
I'm in Wicket, not in PHP I will need to bounce back something similar.
I was hoping that I could just call:

getRequest().write(....);

However, it's not showing up. What is the recommended way of writing
directly to the response object (for this, or RSS feeds, etc..). Do I
have to create a fake txt/xml page that I'm bouncing back, or can I just
write plain text back via the HTTP Response object?

Any help would be appreciated.

Best,

Michael


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


RE: Writing directly to the HTTP Response object?

Posted by Michael Mehrle <mi...@ask.com>.
Yeah, we actually talked about exactly that a few minutes ago. We
suspected that it writes it to the object but is not actually streaming
it out.

I tried your code below and my text shows up when I call the page
directly. So, it must be that [fill in explicit of your choice]
JavaScript... oh joy.

Thanks for your input - enjoy your weekend.

Michael


-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Friday, March 28, 2008 2:44 PM
To: users@wicket.apache.org
Subject: Re: Writing directly to the HTTP Response object?

wicket is probably buffering the response, so you should try
((webresponse)getresponse).gethttpservletresponse().getoutputstream().wr
ite

-igor


On Fri, Mar 28, 2008 at 2:16 PM, Michael Mehrle <mi...@ask.com>
wrote:
> I have a non-Wicket AJAX request call a Wicket page to process some
data
>  (it's that jQuery file uploader I was working on). Now, the PHP
example
>  that came with that jQuery based file uploader writes out some status
>  information to the AJAX JS script via HTTP Response like this (I'm no
>  PHP coder):
>
>  { echo "{";
>  Echo "error: ': . $error . "',\n";
>  Echo "msg: '" . $msg . "'\n";
>  Echo "}"
>
>  That's the message that the JS will use to show the status. Now,
since
>  I'm in Wicket, not in PHP I will need to bounce back something
similar.
>  I was hoping that I could just call:
>
>  getRequest().write(....);
>
>  However, it's not showing up. What is the recommended way of writing
>  directly to the response object (for this, or RSS feeds, etc..). Do I
>  have to create a fake txt/xml page that I'm bouncing back, or can I
just
>  write plain text back via the HTTP Response object?
>
>  Any help would be appreciated.
>
>  Best,
>
>  Michael
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: Writing directly to the HTTP Response object?

Posted by Johan Compagner <jc...@gmail.com>.
thats the way to do it yes
always work with RequestTargets to write stuff

johan


On Fri, Mar 28, 2008 at 11:25 PM, Michael Mehrle <mi...@ask.com>
wrote:

> Actually, your line throws IllegalStateException: STREAM
>
> I tried this, which seems to work as well and doesn't throw that
> exception:
>
> RequestCycle.get().setRequestTarget(new IRequestTarget() {
>        public void respond(RequestCycle requestCycle) {
>                Response rep = requestCycle.getResponse();
>                Rep.write("foo");
>        }
> });
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Friday, March 28, 2008 2:44 PM
> To: users@wicket.apache.org
> Subject: Re: Writing directly to the HTTP Response object?
>
> wicket is probably buffering the response, so you should try
> ((webresponse)getresponse).gethttpservletresponse().getoutputstream().wr
> ite
>
> -igor
>
>
> On Fri, Mar 28, 2008 at 2:16 PM, Michael Mehrle <mi...@ask.com>
> wrote:
> > I have a non-Wicket AJAX request call a Wicket page to process some
> data
> >  (it's that jQuery file uploader I was working on). Now, the PHP
> example
> >  that came with that jQuery based file uploader writes out some status
> >  information to the AJAX JS script via HTTP Response like this (I'm no
> >  PHP coder):
> >
> >  { echo "{";
> >  Echo "error: ': . $error . "',\n";
> >  Echo "msg: '" . $msg . "'\n";
> >  Echo "}"
> >
> >  That's the message that the JS will use to show the status. Now,
> since
> >  I'm in Wicket, not in PHP I will need to bounce back something
> similar.
> >  I was hoping that I could just call:
> >
> >  getRequest().write(....);
> >
> >  However, it's not showing up. What is the recommended way of writing
> >  directly to the response object (for this, or RSS feeds, etc..). Do I
> >  have to create a fake txt/xml page that I'm bouncing back, or can I
> just
> >  write plain text back via the HTTP Response object?
> >
> >  Any help would be appreciated.
> >
> >  Best,
> >
> >  Michael
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Writing directly to the HTTP Response object?

Posted by Michael Mehrle <mi...@ask.com>.
Actually, your line throws IllegalStateException: STREAM

I tried this, which seems to work as well and doesn't throw that
exception:

RequestCycle.get().setRequestTarget(new IRequestTarget() {
	public void respond(RequestCycle requestCycle) {
		Response rep = requestCycle.getResponse();
		Rep.write("foo");
	}
});

-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Friday, March 28, 2008 2:44 PM
To: users@wicket.apache.org
Subject: Re: Writing directly to the HTTP Response object?

wicket is probably buffering the response, so you should try
((webresponse)getresponse).gethttpservletresponse().getoutputstream().wr
ite

-igor


On Fri, Mar 28, 2008 at 2:16 PM, Michael Mehrle <mi...@ask.com>
wrote:
> I have a non-Wicket AJAX request call a Wicket page to process some
data
>  (it's that jQuery file uploader I was working on). Now, the PHP
example
>  that came with that jQuery based file uploader writes out some status
>  information to the AJAX JS script via HTTP Response like this (I'm no
>  PHP coder):
>
>  { echo "{";
>  Echo "error: ': . $error . "',\n";
>  Echo "msg: '" . $msg . "'\n";
>  Echo "}"
>
>  That's the message that the JS will use to show the status. Now,
since
>  I'm in Wicket, not in PHP I will need to bounce back something
similar.
>  I was hoping that I could just call:
>
>  getRequest().write(....);
>
>  However, it's not showing up. What is the recommended way of writing
>  directly to the response object (for this, or RSS feeds, etc..). Do I
>  have to create a fake txt/xml page that I'm bouncing back, or can I
just
>  write plain text back via the HTTP Response object?
>
>  Any help would be appreciated.
>
>  Best,
>
>  Michael
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: Writing directly to the HTTP Response object?

Posted by Igor Vaynberg <ig...@gmail.com>.
wicket is probably buffering the response, so you should try
((webresponse)getresponse).gethttpservletresponse().getoutputstream().write

-igor


On Fri, Mar 28, 2008 at 2:16 PM, Michael Mehrle <mi...@ask.com> wrote:
> I have a non-Wicket AJAX request call a Wicket page to process some data
>  (it's that jQuery file uploader I was working on). Now, the PHP example
>  that came with that jQuery based file uploader writes out some status
>  information to the AJAX JS script via HTTP Response like this (I'm no
>  PHP coder):
>
>  { echo "{";
>  Echo "error: ': . $error . "',\n";
>  Echo "msg: '" . $msg . "'\n";
>  Echo "}"
>
>  That's the message that the JS will use to show the status. Now, since
>  I'm in Wicket, not in PHP I will need to bounce back something similar.
>  I was hoping that I could just call:
>
>  getRequest().write(....);
>
>  However, it's not showing up. What is the recommended way of writing
>  directly to the response object (for this, or RSS feeds, etc..). Do I
>  have to create a fake txt/xml page that I'm bouncing back, or can I just
>  write plain text back via the HTTP Response object?
>
>  Any help would be appreciated.
>
>  Best,
>
>  Michael
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

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