[Split] Using HTTP for data transfer
-
hi volker,
I want to design a app using which user would fill in some data ,for example his user id & after he clicks "SEND" button that user id should get transfferd to a specific url(using HTTP protocol). Once it reaches to that respective url some response is sent back to the user.
I have searched many examples but I am not able to find appropriate application that would explain how to achieve this.
Can you guide me through this? -
First of all:
Please do not add completely new questions to an existing thread dealing with another topic, just open a new thread describing your problem. For this I have split off your question to a new thread.Regarding your question:
Have a look at [[Doc:QNetworkAccessmanager]] and its accompanying classes. It provides what you need. Please search DevNet and the forums, countless examples have been posted already. The docs provide you some examples too, as well as the examples and demos included in the Qt sources. -
Go to the link "forum" on top of this page. This will open another page with all the subforums. Pick one by clicking on it.
In the subforum you get a green button to start a new topic.Also "this help page":http://developer.qt.nokia.com/wiki/ForumHelp might help you.
Cheers
-
Hii i have found a example that somehow resembles my requirements.
but the problem now is that I am not able to include header file <QNetworkAccessManager> in my program. the application is giving error "No such File or Directory".
what can be the actual problem? -
hiii,
I am trying to write a program that can send request using parametrized URL , for that purpose I am trying to include <QNetworkAccessManager.h> header file but the application is giving error as "No such file or directory".
Am I doing some mistakes?
How can I include this header file in my application? -
I linked the network module to my .pro file nw the header file is getting included...thank u Kxyu!!
I have written a very simple program to post parameters in 'key->value' pair using 'connect_server' slot but the values are not getting posted on the server for some strange reasons. Following is my code,can you tell me what is the mistake in it?
-
@
#include "mynetclass.h"
#include "ui_mynetclass.h"mynetclass::mynetclass(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::mynetclass)
{ui->setupUi(this);
connect_server();
}
mynetclass::~mynetclass()
{
delete ui;
}void mynetclass::connect_server()
{
QNetworkAccessManager *manager = new QNetworkAccessManager();QString strurl= "http://anush/alva/SlCustomObject_AndroidCalls?Param_one=Pranj& Param_two=51\\anush\nj_logs\salva";
QUrl url( strurl, QUrl::TolerantMode );
QNetworkRequest request;
request.setUrl(url);
manager->post(request,url.encodedQuery());
}
@[EDIT: code formatting, please wrap in @-tags, Volker]
-
-
You send the parameters twice (as parameters to the URL and as post payload).
And now, if you did tell us what happens on the server side (or what not and what you've expected), we could be of a little bit more help.
Please read and understand http://www.catb.org/~esr/faqs/smart-questions.html - by providing meaningful information (and not only a dump of some C++ code without comments) you're more likely to get useful answers.
-
@
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;public class SlCustomObject_AndroidCalls extends HttpServlet
{public void init(ServletConfig config) throws ServletException
{
try
{
super.init(config);
}
catch(Exception e){Logger.toLog("Android ","SlCustomObject_AndroidCalls","init: Exception " + e);}
}public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{try
{doPost(req,res);
}
catch(Exception e)
{
Logger.toLog("Android ","SlCustomObject_AndroidCalls","doGet: Exception "+e);
}
}
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
try
{
String stParam_one=""; String stParam_two="";
if(req.getParameter("Param_one")!=null)
{ stParam_one = req.getParameter("Param_one").toString().trim(); }
if(req.getParameter("Param_two")!=null)
{ stParam_two = req.getParameter("Param_two").toString().trim(); }
Logger.toLog("Android ","SlCustomObject_AndroidCalls","**** Call In Servlet ******");
Logger.toLog("Android ","SlCustomObject_AndroidCalls","stParam_one: "+stParam_one+" stParam_two: "+stParam_two);
}
catch(Exception e) {}
}//end of doPost() method
}//End of SlLogin servlet
@ -
That's nicely formatted and indented code with a sweet bunch of empty lines that we all love to look at...
Sorry, but do you really expect answers from that? At least a hint, what's in your sever logs would be of help.
You've been told what to do and what to write multiple times now, so I'm out here from this point. I'm not convinced you deserve any help after being that "cooperative", sorry. I'm not after that you give me a single bit and I have to subserviently beg for another little piece of information.
Please read and understand http://www.catb.org/~esr/faqs/smart-questions.html
-
Hello Volker...
This is for the first time that I am communicating my queries to any expert on a forum,so please forgive me if my way of questioning have caused any inconvenience to you..
I'll take care that I provide sufficient information before posting my queries. -
Ok, so you're new to these kind of media, which explains things. Just some tips for the future, which make it much more likely that you get meaningful answers:
- always remember, that the readers in a forum do know nothing about your project, so give decent background information
- describe what you want to achieve, how you implement it and what is the result (in your case: what arrives (and what not) at the Java server side)
- if you post code, boil it down to the absolute minimum, leave out stuff that does not "contribute" to the problem
http://www.catb.org/~esr/faqs/smart-questions.html has some more tips for behaving "nicely".
So, for your current problem:
what arrives (and what not) at the Java server side?