httpclient - Tapestry, request processing from another application -
i'have 2 web appli, tapestry appli , simple web appli(servelt). in tapestry appli , have form, , when it'll sent, call httpclient sending informations author appli using apache's httpclient.
void onsubmitfromform() { try { httpclient client = new defaulthttpclient(); httppost post = new httppost("http://localhost:8080/appli2/recep"); post.setheader("referer", "http://localhost:9090/app1/start"); list<namevaluepair> param = new arraylist<namevaluepair>(); param.add(new basicnamevaluepair("_data", getdata()); post.setentity(new urlencodedformentity(param)); httpresponse response = client.execute(post); response ????? } catch (exception e) { e.printstacktrace(); } } and in servelt recep of simple web appli(2) same below
protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { // todo auto-generated method stub try { httpclient client = new defaulthttpclient(); httppost post = new httppost(request.getheader("referer")); post.setheader("p",getp()); client.execute(post); } catch (exception e) { e.printstacktrace(); } } so, recep reviev data form it'cannot response it, i'would tapersty appli recieve param 'p' simple web appli ?
if i'm correct want tapestry application post form data received form submit within tapestry servlet running on application.
if want missing haneling of request , constructing response in servlet. because both tapestry page , servlet post'ing meaning neither constructs response httpclient deal with.
in servlet could:
public void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/plain"); printwriter out = response.getwriter(); out.println(getp()); out.close(); } and deal response in tapesty form handler.
Comments
Post a Comment