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 8963971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:28:44+00:00 2026-06-15T16:28:44+00:00

I am using Eclipse Indigo and Tomcat 7.0. I have a Swing application, project

  • 0

I am using Eclipse Indigo and Tomcat 7.0. I have a Swing application, project “Controller” with package “gui”. With this application, I am creating a controller-tool for “setting” machine informations. I have several hashmaps, where the information of the Swing-elements are stored (20 similar panels, but containing different informations, like name, status, etc.).

I wanted to use a servlet to create a JSON file, containing these infos (I have to get the data somehow to my android application, and for me it JSON seemed a good choice). My servlet can be connected via localhost:8080/CommunicationBase/JSONServlet That’s where I have my problems: I cannot use my Swing application in the Dynamic-Web-Service project of my servlet.

A little example of my servlet:

public class JSONServlet extends HttpServlet {
    /*this is in my dynamic-web-service-project "CommunicationBase" */

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        JSONArray arrayObj = new JSONArray();
        arrayObj.add("Machine #1");
        arrayObj.add("Status: Down");

        PrintWriter out = response.getWriter();
        out.println(arrayObj);

        arrayObj = new JSONArray();
        arrayObj.add("Machine #2");
        arrayObj.add("Status: Running");        
    }
}

How can I put my hashmap informations from the Swing application to the Servlet? Can I create just a single Java class into my “Controller” project, and add a web.xml? If yes, where? Or how do I do that?

Can I also change the JSON information of the servlet from my Android app then somehow easily? So that the information in my Swing application will change (Android and Swing application will always work in the same LAN).

  • 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-15T16:28:45+00:00Added an answer on June 15, 2026 at 4:28 pm

    Android Client:

                Socket socket = new Socket(serverIPAddress, SERVER_PORT);
                BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
                String help = reader.readLine();
                JSONObject myJson = new JSONObject(help);
    

    Swing Application:

     Thread thread = new Thread() {
            @Override
            public void run() {
                try {
                //  while(socket.isConnected()){
    
                    writer = new OutputStreamWriter(socket.getOutputStream(), "UTF-8");
                    reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
    
                    JSONObject myJson = new JSONObject();
                    JSONArray list = new JSONArray();
                    ... //do something useful for JsonTransformation
    
    writer.write(myJson.toString());
    
     }
    }catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    closeSocket();
                }
     }
    

    did the job. thx for your help!

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

Sidebar

Related Questions

I am using the eclipse indigo and tomcat 6. I have two projects, one
I am using Eclipse Indigo RC4 with EGit (bundled). I have a project which
I have just started using eclipse Indigo for Scala development. Is there a setting
This is how error happened.Now i am using Eclipse Indigo integrated with apache tomcat
I'm on Windows XP, using Eclipse Indigo, Tomcat 6.0.33, and have the Maven plugin
I have developed a web application based on struts2.2.1, using Eclipse indigo IDE with
I'm using Eclipse Indigo and have a Maven project which uses an annotation processor
I am using Eclipse Indigo with an Android/NDK mixed project. I've added C++ nature
I have successfully been using the eclipse Indigo internal browser to view my web
We will be using eclipse(Helios or Indigo) for multiuser environment for development. For this

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.