Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8621213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:46:12+00:00 2026-06-12T06:46:12+00:00

New to java, GWT and interacting with APIs. I have what I hope is

  • 0

New to java, GWT and interacting with APIs. I have what I hope is a simple question.

I have successfully interacted with a REST API using the following curl command:

curl -d "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=xxxxxxxxxxx&INPUT_DATA=<?xml version=%221.0%22 encoding=%22utf-8%22?><Operation><Details><requester>Me</requester><subject>Test</subject><description>Testing curl input</description></Details></Operation>" http://xx.xx.xx.xx/sdpapi/request/ 

Now, from a tutorial, I have the following code that I am hoping will post a request to the remote server just like the curl command above.

What I am trying to figure out (with no love from google) is how I pass the OPERATION_NAME, TECHNICIAN_KEY and INPUT_DATA parameters in when I am sending the URL. Any suggestions, tutorials, etc. will be appreciated.

The following is from my server side implementation interface:

@Override
public String postToRemoteServer(String serviceUrl)
        throws HelpDeskTestException {

    try {
        //dividing url into host: http://some.server
        //path: a/path/in/it
        //and parameters: this=that&those=others

        int hostStart= serviceUrl.indexOf("//");

        int pathStart= serviceUrl.substring(hostStart + 2).indexOf("/");

        int parameterStart= serviceUrl.substring(hostStart + 2 + pathStart).indexOf("?");

        final String serverHost= serviceUrl.substring(0, hostStart + pathStart + 2);

        final String serverPath= serviceUrl.substring(hostStart + 3, 
                hostStart + pathStart + 2 + parameterStart);

        final String serverParameters= serviceUrl.substring(hostStart + pathStart + 3 + parameterStart);

        final  URL url = new URL(serverHost);

        final URLConnection connection= url.openConnection();
        connection.setDoOutput(true);

        final OutputStreamWriter out= new OutputStreamWriter(connection.getOutputStream());

        final BufferedReader in= new BufferedReader(new InputStreamReader(
                connection.getInputStream()));

        out.write("POST " + serverPath + "\r\n");
        out.write("Host: " + serverHost + "\r\n");
        out.write("Accept-Encoding: identity\r\n");
        out.write("Connection: close\r\n");
        out.write("Content-Type: application/x-www-form-urlencoded\r\n");
        out.write("Content-Length: " + serverParameters.length() + "\r\n\r\n" +
            serverParameters + "\r\n");


        String result = "";
        String inputLine;

        while ((inputLine=in.readLine()) != null) {
            result+= inputLine;
        }

        in.close();
        out.close();

        return result;

    }  catch (final Exception e) {
        throw new HelpDeskTestException();

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:46:13+00:00Added an answer on June 12, 2026 at 6:46 am

    Consider using this library: Apache HttpClient. Here is an example of making a POST request with it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code adding an ActionListener to a JTextField: chatInput.addMouseListener(new java.awt.event.MouseAdapter() {
Does anyone have experience writing a Facebook application using GWT with GAE? I'm new
I'm fairly new to GWT and have never worked with Java Servlets before. I
I'm new to GWT and also fairly new to doing Java web development, using
I'm using Channel API (GAE Java SDK + GWT) and I'm trying to create
I'm pretty new with EJB's and GWT but I've been using Java for a
Using GWT I have a Java class: public class Pojo { private String name;
When creating a new Java project in IntelliJ IDEA, the following directories and files
I'm new to Google Web Toolkit (using as plug-in in Eclipse). Why the java
I have the following code from a GWT Project that is part of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.