You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by nooblet <cy...@gmail.com> on 2013/03/31 00:23:42 UTC

Reading POST data from standalone application

I have tried many different things here, googled extensively and while almost
there, still need the last centimeter to get it working. 
Basicly I want to post some binary data from an java applet, but the applet
part is irrelevant, for proof of concept i am POSTing from a standalone java
client.

This is the client code.

URL url = new URL("http://somesite");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setFixedLengthStreamingMode(6);
OutputStream out = null;
out = conn.getOutputStream();
out.write("hello\n".getBytes());
out.flush();

Now, on the out.flush() My wicket page get hit fine, heres the page (extends
WebPage)


public MyWicketPage(final PageParameters parameters) {
      WebRequest wr = (WebRequest) getRequest();
      HttpServletRequest hsr = wr.getHttpServletRequest();
      if (hsr.getMethod().equalsIgnoreCase("post")) {
              byte[] data = IOUtils.toByteArray(hsr.getInputStream());
              logger.trace("!! "+data.length);
      }
}

Problem is that data.length is 0, there is nothing in the stream.
So I am obviosly doing something very wrong .. Pointers please ? :-)









--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Reading-POST-data-from-standalone-application-tp4657664.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Reading POST data from standalone application

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Any reason why you don't use: parameters.get("theParameterName") ?
To construct the PageParameters Wicket needs to read the input stream for
your convinience.


On Sun, Mar 31, 2013 at 4:56 PM, nooblet <cy...@gmail.com> wrote:

> I might add that popping in a standard HttpServlet and mapping in web.xml
> works just fine, the HttpServletRequest contains all my pretty data ..
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Reading-POST-data-from-standalone-application-tp4657664p4657665.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Reading POST data from standalone application

Posted by nooblet <cy...@gmail.com>.
I might add that popping in a standard HttpServlet and mapping in web.xml
works just fine, the HttpServletRequest contains all my pretty data ..



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Reading-POST-data-from-standalone-application-tp4657664p4657665.html
Sent from the Users forum mailing list archive at Nabble.com.

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