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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:11:45+00:00 2026-05-23T18:11:45+00:00

I am creating a servlet(proxy server) which handles multiple request from the client.I do

  • 0

I am creating a servlet(proxy server) which handles multiple request from the client.I do Know how to handle a muliple request top the same servlet.what should i have to use to handle the multiple request.

For example I have two HTML page.which send the request to the same servlet at the same time.how to handle the request from both the pages and how to respond to those pages (each one separately)

this is my servlet code.

   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String ip_Address=null;
    int ip_port=0;
    String request_action = null;
    String Target=null;
    String Action = null;
    String Setchannel = null;
    String AssetID=null;
    String AssetURI=null;
    String Position=null;
    String Speed=null;
    String Keywords=null;

    Connection con = null;

    ResultSet rs = null;
         /* String myMessageText = "action=play;assetId=1000;assetURI=/movies/avatar.ts;position=123.32";

          String[] parts=myMessageText.split(";");
          System.out.println(parts[3])*/;
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          out.println("<html>");

          out.println("<body>");
          out.println("<h1>Servlet JDBC</h1>");




        try {
            ip_Address=request.getRemoteHost();
            ip_port=request.getRemotePort();
            request_action = request.getParameter(CommonConstants.REQ_PARAM);
            Target=request.getParameter(CommonConstants.TARGET_PARAM);
            Action=request.getParameter(CommonConstants.ACTION_PARAM);
            Setchannel=request.getParameter(CommonConstants.CHANNEL_PARAM);
            AssetID=request.getParameter(CommonConstants.ASSETID_PARAM);
            AssetURI=request.getParameter(CommonConstants.ASSETURI_PARAM);
            Position=request.getParameter(CommonConstants.POSITION_PARAM);
            Speed=request.getParameter(CommonConstants.SPEED_PARAM);
            Keywords=request.getParameter(CommonConstants.KEYORDS_PARAM);


        } 
        catch(Exception e)
        {


        }

          try {
             // Establish the connection. 
             SQLServerDataSource ds = new SQLServerDataSource();
             ds.setUser("sa");
             ds.setPassword("password123");
             ds.setServerName("ENMEDIA-EA6278E\\ENMEDIA");
            ds.setDatabaseName("IBC_ProxyServer");

             con = ds.getConnection();

             // Execute a stored procedure that returns some data.
             Statement stmt = con.createStatement();



           String sql="INSERT INTO  " + CommonConstants.Table_name + " ("+CommonConstants.Column1_ipaddress+","+CommonConstants.Column2_ip_port+","+CommonConstants.Column3_req+","+CommonConstants.Column4_target+","+CommonConstants.Column5_action+","+CommonConstants.Column6_channel +","+CommonConstants.Column7_assetID +","+CommonConstants.Column8_assetURI +","+CommonConstants.Column9_position +","+CommonConstants.Column10_speed +","+CommonConstants.Column11_keywords+" ) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
            //stmt.executeUpdate("INSERT INTO " + CommonConstants.Table_name + "("+CommonConstants.Column1_ipaddress+","+CommonConstants.Column2_ip_port+","+CommonConstants.Column3_req+","+CommonConstants.Column4_target+","+CommonConstants.Column5_action+","+CommonConstants.Column6_channel +","+CommonConstants.Column7_assetID +","+CommonConstants.Column8_assetURI +","+CommonConstants.Column9_position +","+CommonConstants.Column10_speed +","+CommonConstants.Column11_keywords+") VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')",ip_Address,ip_port,request_action,Target,Action,Setchannel,AssetID,AssetURI,Position,Speed,Keywords);
           PreparedStatement pst = con.prepareStatement(sql);
           pst.setString(1, ip_Address);
           pst.setLong(2, ip_port);
           pst.setString(3, request_action);
           pst.setString(4, Target);
           pst.setString(5, Action);
           pst.setString(6, Setchannel);
           pst.setString(7, AssetID);
           pst.setString(8, AssetURI);
           pst.setString(9, Position);
           pst.setString(10, Speed);
           pst.setString(11, Keywords);
           pst.executeUpdate();
           con.close();
           out.println("<br>"+ip_Address+"</br>");
           out.println("<br>"+ip_port+"</br>");
           out.println("<br>"+request_action+"</br>");
           out.println("<br>"+Target+"</br>");
           out.println("<br>"+Action+"</br>");
           out.println("<br>"+Setchannel+"</br>");
           out.println("<br>"+AssetID+"</br>");
           out.println("<br>"+AssetURI+"</br>");
           out.println("<br>"+Position+"</br>");
           out.println("<br>"+Speed+"</br>");
           out.println("<br>"+Keywords+"</br>");

           out.println("</body></html>");  
         } catch (Exception e) {
             System.err.println("Got an exception! ");
             System.err.println(e.getMessage());
         }



}

Suppose there is two clients A and B
A sends http://companion_proxy/ocl.cgi?req=cnc_cmd;target=12;action=setchannel;channel=34

B sends http://companion_proxy/ocl.cgi?req=registerdevice;type=CAM1;name=Livingroom

I have to getParameter of A and store it in database and same way i have to store the data of B in another table.I have to send the response to these clients as

A ——> 1

B——–>target=12;action=setchannel;channel=34

how to do the response to these two different clients

  • 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-05-23T18:11:46+00:00Added an answer on May 23, 2026 at 6:11 pm

    Typically you do not have to care about the fact that multiple requests are being processed simultaniosly. Application Server does it for you. Your servlet should be stateless, i.e. avoid storing any information in servlet’s class variables. If you need such kind of information use request and session attributes instead.

    I’d recommend you to refer to one of multiple available tutorials on Servlet API and servlet/jsp development at all. For example in your case more than 50% of code of your servlet generate HTML response. Obviously it is much more convenient to implement this kind of logic in JSP.

    BTW there are some naming conventions in java. For example variables names must start with small letter.

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

Sidebar

Related Questions

Let say I have the following desire, to simplify the IConvertible's to allow me
I have a new web app that is packaged as a WAR as part
I want the messagebox to only show if the number is equal to 0.

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.