How can I know whether the Servlet is sending a response!!!

Hello,
My question is this :
How do I know whether that server outputstream is sending me a response or not?
I have opened the Client InputStream to recieve a response from a servlet,but how
can i be sure that i will receive a response from the servlet?
I cud be waiting for an 15 expecting a response but havent received one..
Is there any way to check whether the servlet is sending me a response?
The reason I am asking is this.
I have written a Java Client that connects to a servlet.It has to wait for a
response from the servlet.It will wait for 5 seconds and if this doesnt recieve
a response,it will return back else it will display the response.
I have set a timer on my client for 5 seconds and a timer on the servlet for 15 seconds.
Essentially,when the client connects,the servlet response is held for 15 seconds
and the client tries for 5 seconds.
But the client is unable to exit without a response.The response comes back in 15 seconds.
The client shud have the message 'Connection Timed Out' after 5 seconds.
This means there is an error somewhere.
As the response takes 15 seconds,the client shudnt recieve one.
So,is there a way I can block the servlet response?
I am using threads and Inner classes for the timer purposes..
Please can any one help me?
ajay
Client code:
public class HttpHandler {
private static String sURL="localhost";
static String sMessage="Hello Server..Client sending Data";
static DataInputStream dis = null;
static HttpURLConnection hpCon=null;
public static void main(String[] args)
sendData(sMessage);
public void TimerTest() {
NewThread nt = new NewThread();
public static void sendData(String sMess)
String response=null;
try{
// Invoke Timer
new HttpHandler.TimerTest();
URL url=null;
String uri = "http://" + sURL + ":8080/servlet/threads.Recieve_Http_Data1";
url = new URL(uri);
hpCon=null;
hpCon = (HttpURLConnection)url.openConnection();
hpCon.setDoOutput(true);
hpCon.setDoInput(true);
// Transfer Data over http
DataOutputStream dos = new DataOutputStream(hpCon.getOutputStream());
dos.writeUTF(sMess);
}catch(IOException e)
{System.out.println("Error in Client " + e); e.printStackTrace();}
} // End of Method sendData
// Inner Class
class NewThread extends Thread
String response;
int i=0;
NewThread()
start();
public void run()
try {
while(i < 5)
System.out.println(i);
Thread.sleep(1000);
try {
dis = new DataInputStream(hpCon.getInputStream());
response = dis.readUTF();
// If response recieved, break off else Loop back.
if(dis !=null)
System.out.println("SERVER RESPONSE : " + response);
dis.close();
break;
}catch(IOException e){System.out.println("Here : " + e);}
i++;
} // End of While.
}catch(InterruptedException e){}
The Servlet
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.io.*;
import java.sql.*;
import java.math.*;
public class Recieve_Http_Data1 extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
doPost(request,response);
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
System.out.println("Server Ready to receive Message from application :");
System.out.println();
BufferedReader br=null;
// Data Read by the Servlet
String sMess="";
DataInputStream dis = new DataInputStream(request.getInputStream());
sMess = dis.readUTF();
System.out.println("Received from Client: " + sMess);
// Send response back after 15 seconds Only.
try {
for(int i=0;i<15;i++)
System.out.println(i);
DataOutputStream dos = new DataOutputStream(response.getOutputStream());
String sResponse = "Hello Client...This is server sending response";
dos.writeUTF(sResponse);
Thread.sleep(1000);
}catch(InterruptedException e){}

I don't know whether you solve your problem or not! Anyway, I have the same problem. The program hangs when getInputStream is called.
DataInputStream dis = new DataInputStream(request.getInputStream());
If you have the answer, please let me know. Thanks!!

Similar Messages

  • Hi anybody there who can help me ha..? My phone 5s was stolen 1 month ago..Find my phone is no a big deal, How can i know whether my phone is in use??

    Hi anybody there who can help me ha..? My phone 5s was stolen 1 month ago..Find my phone is no a big deal bcz it seems to be wiped out all data including settings. it might be in use somewhere turning new fresh Gadget.  How can i know whether my phone is in use??

    You would know for a fact if the device is in use, but if you go back to the find my iPhone app in iCloud.com, you can either select to erase it, or place it in lost mode, in which case, once the device makes a connection to the internet, it will automatically go into that mode.

  • HT201328 how can I know whether my IME is blocked or not?

    How can I know whether my IME is blocked or not?

    Ask your wireless carrier.
    Where did you acquire this iPhone? Common scam
    is to sell iPhone in working condition so buyer can see
    it works, then seller reports iPhone as stolen/lost for
    insurance claim. Insurance company works with
    cellular provider to blacklist the iPhone and suddenly
    it no longer works.
    Or is your iPhone still locked to a wireless carrier as
    you imply in https://discussions.apple.com/thread/5001327?tstart=0

  • How can I know whether PI is ready to run

    Hi.
    How can I know whether PI is ready to run?
    ex)
    MMC status is green.
    J2EE Engine status is "10"(RUNNING)
    http://<host>:<port>/AFW/rtc returns some status
    I want to check the whether PI is ready to run periodcically.
    Can I use sapcontorl interface?
    regards,

    Gaspard,
    >MMC status is green.
    >J2EE Engine status is "10"(RUNNING)
    > Check the ABAP Stack
    If all this good, PI  is ready to go ahead
    Cheers
    Agasthuri Doss

  • How can i know if the sync process is done after a bookmark adding or so such and when it is processing , immediately after changes or what?

    how can i know if the sync process is done after a bookmark adding or so such and when it is processing , immediately after changes or what?

    I don't know whether you solve your problem or not! Anyway, I have the same problem. The program hangs when getInputStream is called.
    DataInputStream dis = new DataInputStream(request.getInputStream());
    If you have the answer, please let me know. Thanks!!

  • How can i know if the face time is working on the iPad before i buy it?

    How can i know if the face time is working on the iPad before i buy it?

    I am plan to buy new ipad2 and i want to check before i buy it, if there is facetime or not?
    As far as i know if it is from KSA there is no face time in, but if it from US there is facetime in?
    And i have the serial number.

  • HT4515 how can i know if the number i am calling is busy or i am on waiting

    How can I know if the number I am calling is busy or I am on waiting? Please let me know.

    If you get a busy signal when calling a number, it is busy.

  • How do I know whether the USB port in my macbook air is 2.0 or 3.0?

    How do I know whether the USB port in my macbook air is 2.0 or 3.0? I really want to use a usb flash drive that has faster read/write speed but I don't kow if it would be supported by my macbook air - I purchased the macbook air from the apple store on autumn 2011, 1.7Ghz Intel Core i5

    Eddy ~ The free Mactracker app shows USB info and much more:

  • How do we know whether the materials maintaine any sales org?

    Hi All, as an ABAPer, how do we know whether the materials maintaine any sales org?

    Hi,
    1.Go to the Table MVKE (Sales Data for Material)
    2.This relates the material with sales organization & distribution.
    3.Give the sales Organization and u will find all the material that correspondance to the sales org.
    Regards,
    Jagadish

  • How can I know if the Oracle software is  64-bit or 32-bit

    Hi all,
    How can I know if the installed Oracle software is 64-bit or 32-bit.Actually I'm using an oracle database 10.0.2 on a Solaris 10.
    Cheers.

    Dear user11191992,
    Please check below link;
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10820/dynviews_3120.htm#REFRN30296
    Here is for the release number;
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10595/dba004.htm#ADMIN11039
    Another way is to enter the database with;
    # sqlplus / as sysdbaHope That Helps.
    Ogan

  • How can I know about the latest updates / versions which when available for all the CC products, without having to install and check it with the Desktoip Creative Cloud Application ?

    How can I know about the latest updates / versions which when available for all the CC products, without having to install and check it with the Desktoip Creative Cloud Application ?

    Thanks for looking into this Jeff!
    I work with an Inventory module software and is responsible for software detection across several computers. Once an updated version comes up, I update our database with latest software details to get it detected if installed on any machines.
    The problem tracking updates with Desktop Creative Cloud Software are;
    1)We have to have it installed with the CC applications in-order to get the notification of the latest updates and have to check everyday.
    2)Only relates to the latest updates, so in-between we may miss a prior update unknowingly.Hence, the remote machines having those updates may not get  detected with the software version update which would create problem in reporting.
    3)For all CC products, there is no base or previous updates available for installation if we miss one.
    I went through the Adobe Products Update pages [Product updates] which holds good when it comes to Acrobat and Reader software which I follow to track down any newer updates but this is inconsistent when it comes to CC products like in After Effects CC, Dreamweaver CC etc...
    So overall to be very specific, is there any one channel I can follow to get the notifications only for the updates on CC products and then may be I can rely on Desktop Creative Cloud for installation if not available anywhere like in product update pages of Adobe ?
    Regards,
    Subrat

  • Money is deducted from my bank account but iTunes show no purchases. How can i know why the amount is deducted ?

    1. Money got deducetd from my account in favor to iTunes store although i purchased nothing.
    2. I checked with iTunes Purchases it confirms that nothing is purchased.
    3. How can i know why the money has been deducted from my sccount ?

    See Here  >  http://support.apple.com/kb/HT3702

  • In Generic Extraction how can we know whether it is Delta Enabled or not?

    In Generic Extraction how can we know whether it is Delta Enabled or not?
    Thanks,
    Pramod.

    Hi Pramod,
    In R/3 use RSO2 tcode and enter your DS name and click "Change / Display" In this "Press F7 or Display Filed List" icon near to Generic Delta.In this Screen if Delta Update is Checked means it supports delta method  otherwise it won't support delta method.
    Note:Assign Points if it helps.
    -Arun.M.D

  • How can we know that the Rule is Generated or Not?

    Hi,,
    After creating the Risk , its suggested to click on Generate Rules Button to Generate the Risk.
    But my question is that how we can know whether the risk is already generated or not..??
    Any table or any change history for this.
    As I can see even after generating the Rule the last update date for the risk is still the same.
    Someone please help me !

    Hi,
    Rule ID numbers are just identifiers for different combinations in same risk. It is just serial number assigned to the combination.
    Example:
    Risk: RISK01
    Function: FUNC01                         Function: FUNC02
    Action:      ZU01                              Action:     XU01
                     ZU02                                              XU02
    Rule ID: 0001 for ZU01 and XU01
    Rule ID: 0002 for ZU01 and XU02
    Rule ID: 0003 for ZU02 and XU01
    Rule ID: 0004 for ZU02 and XU02
    But if you remove action ZU02 and XU01 in your update
    Remaining
    Action:
    ZU01                        
    Action:
    XU02
    Rule ID: 0001 for ZU01 and XU02
    So it will just update the respective risk with same rule id assignment to new combination.
    To achieve more clarity try to build one risk in you system.
    You can definitely go into the risk to see if the new rule generated has changes reflected as per update or not. Try this all with example so you would have clarity.
    BR,
    Mangesh

  • How can i know that the application is written in a correct way???

    Dear sirs...
    it seems a little silly, but assume that i wrote an applicaion, how can i
    1- be sure that its performance is good, i.e. did i designed the application to be fast?
    2- if it is using SSL, how can i make sure the performance is high?
    3- before the applicaion is installed should i use any specific tuning?
    4- should i do some tuning to the database,& as? i know how to install the AS, & DB, and how to make the application work, but i want it to work as good as possible
    thanks for any help & happy new year
    regards

    you need load testing tool for that...
    you can test your application with "Web Performance Trainer".. it supports ssl, multiple users (up to 5000 simultaneous), etc...
    i use it and it is very good... anyway i havent try it with UIX only plain JSP but i think it shoud work with UIX too...
    ofcourse you have to load database with lots of dummy records to have valid results...
    my expirience is that for single standallone oc4j instance on heavy load maximum is 50-100 simultaneous users over ssl aes-256 (but load testing tool, oc4j and db are on the same computer which have only 2 GB of ram, and DB is only light loaded with with several hundred records, and each of those 50-100 concurent users have its own login name, each on its own separate SSL chanel.. so encryption load is really really heavy) on real deplyment system performance should be much much gerater, because DB, AS, and OC4J's should be on diferent machines each...

Maybe you are looking for

  • Why is my facebook widget not showing?

    Hello, I'm using the new social wiget to add a facebook follow button to a client's site, but it does not upload to the catalyst site nor can I view it in preview. I have entered the full URL o the client's facebook page to the 'profile url checkbox'

  • PROBLEM WITH FILE PROCESSING

    Hello I've written a program to find a keyword in a file (or files). It compiles fine. When I run the program I get a FileNotFoundException. It is referencing the first argument in the command line, which is my keyword. I don't understand, since I se

  • RGB Colour change after save for web.

    I recently had a folder full of images that I cut out and placed on a grey #e9e9e9 background, after using adobe photoshops Save for web feature, I saved them as 356 colour gif files. However when Ive uploaded them to the web I notice the grey #e9e9e

  • CHECK PRINTING SET UP IN PAYMENTS

    Hi , Please let me know how to setup check printing in oracle appsR12 ..it is urgent please help us its very greatful to ... THANKS, USER.

  • HT201412 screen locked how to unlocked without itunes

    help with my locked screen without using itunes