I have a problem.. I use "GWT"; I have a string in client side.
I would send this string to server with a HTTP POST request but I have no idea how to do this..
What is the code that I have to write on client side and server side???
please help
I think you should have a look into the official documentation:
Dev Server Commmunication
I am not a big fan of RPC, so I'd suggest to you the HTTP calls here
As the backend I'd create a REST architecture for handling the requests.
Related
I am working client -server architecture, i need to install one fingerprint device in client side, then i need to run some application in client side using server side to get the fingerprint image from client to server which has taken from the client side.I am planning like, applets are client sides and jsp are at server sides.please help me out.
Your design looks fine to me, but what is the exact issue that you are facing.
From the Applet you need to call a servlet by using some API like Apache HttpClient.
http://hc.apache.org/httpclient-3.x/
You can then use the response of the Http call in your client (Applet).
For some reasons I need to develope an own HTTP client. I managed working with the HTTP protocol, but I don't know how to send it via java...
For example, I got the following request message I want to send (I couldn't test it, so I am not sure that it is in a correct format):
GET http://example.com HTTP/1.1
Transfer-Encoding:UTF-8
someOtherParam=thatIsThis&name=value
All I could find was making up a connection using URL.openConnection() - but with that connection, I can't send the whole message, but have to put the header values via the connection.addRequestProperty() method.
Can anyone help me and tell me how to send such a message to a server?
(And yes; I do know libraries like Apache HttpComponents :))
Best greetings,
Martin Bories
thanks for your help - Sockets did it :).
For anyone who is running into the same problem: Use sockets - you can simply write and receive messages and implement an own HTTP implementation.
I have written a simple HTTP server using Java and want to send some additional information (puzzle parameters and a small puzzle solver program) to the client i.e. a regular browser.
Similarly, the browser is also supposed to send information (solution) back to the server.
Is there a way to do this by just transmitting this information over the HTTP headers?
Thanks a lot
the headers are usually used to add http protocol relevant information.
You should probably use either the body of the response or cookies to add the needed information.
Adding a cookie is done using the header so it kind of fits what you are asking for.
But I wonder why you need to put it in the header? it seems like what you are asking for is url parameters (client to server) and response body (server to client).
I need to send a request from a servlet to an application running in other environment (IIS) with certain information in custom headers.
I know redirecting doesn't send the headers and getServletContext().getRequestDispatcher(url) is to be used in the servlet's context only. Has anybody made this work in some other way? I was thinking in using HttpURLConnection, but would it finally redirect the browser to the targeted app ?
Thanks in advance
You can't redirect from your servlet to the external server and keep the headers, and you can't forward the incoming request to other context.
What you could do, is to use the HttpURLConnection (or other http client library such as HTTPClient) to make the request (with the custom headers you need) to the remote server and, once the operation is complete, redirect the user to the external site (customm headers are not set in this redirection).
This is a little tricky, if you elaborate your question (what do you really need to do) we can probably think about other alternatives.
AJAX? You can send some JavaScript code to the browser which sends a request to the ISS and handle (shows) its answer. It's possible to set http headers with XMLHttpRequest but it needs client side JavaScript coding and you have to find a way to send cross domain requests.
I am developing a software which will be communicating with a server using HTTP (but it is not a web browser). Since the server part is not ready yet, I would like to debug my client software by sending HTTP messages to it. I know that I can send HTTP requests using Curl. But I am not sure if that is sufficient here.
I'm imagining an environment where I send a request from my application, check that it is correct using Wireshark and then reply to the request using some software. Using Curl, I think I would have open a listening port..?
I'd use a simple node.js server for this. You can write your own HTTP server in a few lines of code an simulate various return codes, response headers or response entities easily: http://nodejs.org/
PS: There are proxies that simply print out the HTTP messages. This might be helpful for you too, because you don't have to deal with WireShark anymore just for HTTP-level logging.
You can't do that with cURL. It is an http client, not a server.
The simplest way to do this is to actually implement a mock server application that just returns a static (i.e. hardcoded) message every time. You can do this using any server-side language you like (php, python, ruby, ...), or, you can even do it without a server side language, using just static files served by a webserver such as apache or nginx.
For example, if the server part (the API) would respond to /articles.json with something relevant (a JSON object containing some articles), you could put a file named articles.json that contains some hand-written data in your server's root. Then, your application would think it's calling an API when it's actually just downloading a static file.
You can use firebug addon of firefox browser to see content of HTTP request/response.
It does't require any server (but of course, if you dont have server which process requests from browser and send responses to browser, you 'll always see response "unable to connect").
If you still need to mock response, you can create simple server which is able to respond with mock responses, for example java servlet at tomcat server, with code like this:
public class MyMockServlet extends HttpServlet {
..
private String mockHeaders = "...";
private String mockResponse = "my response";
public void service(HttpRequest request, HttpResponse response){
setHeaderAndBodyInResponse(response);//your method
}
}