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

  • Home
  • SEARCH
  • 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 8407051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:16:37+00:00 2026-06-09T23:16:37+00:00

My client does not implement the HttpServlet interface. It connects to an HttpServlet running

  • 0

My client does not implement the HttpServlet interface. It connects to an HttpServlet running remotely

 url = new URL("http://tomcat-location:8180/myContext");

This is what it uses to send messages to the servlet. But how can it get back responses? When I try to read from this location, I am reading the content of the specified page. Maybe my whole approach is wrong and this is not how the client and the servlet should talk to each other? How can I make them talk in a simple way? It seems that using the URL, they are communicating by posting and reading on that page. Is there any other way they can talk without writing on the page?
Thanks

  • 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-09T23:16:38+00:00Added an answer on June 9, 2026 at 11:16 pm

    Try this:

    public static String getURLData( String url ) {
    
        // creates a StringBuilder to store the data
        StringBuilder out = new StringBuilder();
    
        try {
    
            // creating the URL
            URL u = new URL( url );
    
            // openning a connection
            URLConnection uCon = u.openConnection();
    
            // getting the connection's input stream
            InputStream in = uCon.getInputStream();
    
            // a buffer to store the data
            byte[] buffer = new byte[2048];
    
    
            // try to insert data in the buffer until there is data to be read
            while ( in.read( buffer ) != -1 ) {
    
                // storing data...
                out.append( new String( buffer ) );
    
            }
    
            // closing the input stream
            in.close();            
    
            // exceptions...  
        } catch ( MalformedURLException exc )  {
    
            exc.printStackTrace();
    
        } catch ( IOException exc ) {
    
            exc.printStackTrace();
    
        } catch ( SecurityException exc ) {
    
            exc.printStackTrace();
    
        } catch ( IllegalArgumentException exc ) {
    
            exc.printStackTrace();
    
        } catch ( UnsupportedOperationException exc ) {
    
            exc.printStackTrace();
    
        }
    
        // returning data
        return out.toString();
    
    }
    

    If you need to work with a proxy you will need to do some more work, since you will need to authenticate. Here you can read something about it: How do I make HttpURLConnection use a proxy?

    If you want a client that works like a browser, you can try the HttpClient from Apache HttpComponentes

    Now, if you need a behavior where the server notifies the client, so you will need to use another approaches, like creating your own server and working with sockets. If you work with a regular browser you can use websockets, but it seems that is not your case.

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

Sidebar

Related Questions

I'm trying to get a FacebookLoginTest running. Problem is: the Symfony2 client does not
My client does not want to have ftp on the production box (understandable). We
I get the following error: Client does not support authentication protocol requested by server;
If I kill the Socket Server process, my Socket client process does not receive
A client credential grant does not return a refresh token (DotNetOpenAuth.OAuth2.AuthorizationServer.PrepareAccessTokenRequest forbids it). But
Inherited properties and MetadataType does not seem to work with client side validation in
How can I implement a web service in WCF such that it does not
Error in NSLog: *** -[NSThread initWithTarget:selector:object:]: target does not implement selector (*** -[Document myTcpClient])
I keep getting thrown an error: This widget's parent does not implement HasWidgets. Of
WCF does not support request streaming (aka streaming upload of large data) over HTTP

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.