BufferReader using reaLine() is not terminating when end of message.

Hi folks,
Newby Java here. I have a situation where I am writing a Server Socket Java program where I am accepting connection from a client and the client is sending messages me. I am able to connected to the client and the client successfully send messages to me, but the problem I am running into is that it's not terminating the while loop when I read to the end of the message using a reaLine(). It's like it's hung up or something...
Here is a copy of the code.....
ss = new ServerSocket(6500, 5);
System.out.println("Listenning........waiting for connection from client");
try {
response = ss.accept();
System.out.println("Accepted connection from client");
InputStream in = response.getInputStream();
System.out.println("Input Stream Opened");
BufferedReader br = new BufferedReader(new InputStreamReader(in));
System.out.println("Buffered Stream Opened");
System.out.println("Server received: " + "\n" );
BufferedWriter bw = new BufferedWriter(new FileWriter("testing001.txt"));
String input = br.readLine();
while (input != null) {
bw.write(input);
bw.newLine();
input = br.readLine();
br.close();
bw.close();
System.out.println("Done receiving message" + "\n" );
OutputStream out = response.getOutputStream();
BufferedWriter buf = new BufferedWriter(new OutputStreamWriter(out));
buf.write(result);
System.out.println("Server sent: "+result);
buf.flush();
buf.close();
response.close();
ss.close();
catch (IOException e) {
System.out.println("Failure accepting connection: " + e);
What am I doing wrong that the while loop does not terminate when it reads to end of the message using this "readLine()"?
It does not execute the next statement after the while-loop unless you disconnect the connection from the client.
Help!

readLine() will wait for more lines forever, or until the other end closes the connection. (For completeness: there are other termination situations too, mostly error conditions.)
You have a multi-line message? Send some kind of an end-of-message line and check for it in your read loop. E.g. "." on a line all by itself. Caveat: if the message itself can contain a line like that you'll need to quote that line somehow. Another approach: send the number of lines in the message first. Requires that you know the number beforehand.

Similar Messages

  • Error 500: String not terminated at end of line.

    Hi,
    I am trying to pass three parameters to a bean class. When I hardcode the values the method is executed correctly. However when I embed the parameters into the calling method I get the error:
    Error 500: String not terminated at end of line.
    The parameters are reqtrieved from the request object, and assigned to page variables. They are picked up and assigned to the variables without a problem.
    Can someone let me know what the issue appears to be?
    Source:
    =====
    <%
    String forename="";
    String surname="";
    String username="";
    username=request.getParameter("Username");
    forename=request.getParameter("Forename");
    surname=request.getParameter("Surname");
    String var;
    var=user.getUserId("<%=username%>", "<%=forename%>", "<%=surname%>");
    %>

    Thanks for the reply. however this reutrns no values back to the browser. Again, hardcoding the values surrounded by quotes ( function expects String ) works fine returning a result.
    Any ideas?

  • Some of my contact names are not appearing when they text message me.  They are just showing up as their numbers. I have them saved in my phone so i am not really sure why their names aren't showing up when they message me?

    some of my contact names are not appearing when they text message me.  They are just showing up as their numbers. I have them saved in my phone so i am not really sure why their names aren't showing up when they message me?

    I have this identical problem.  For a while my group texts didnt show up on my ipad.  Then one day they did, maybe everyone in the group started using the same os version or something.  Ever since my first reply to the group there have been complaints of multiple threads.  I can not find a pattern for when my group text's decide they want to create a new thread. (it doesnt happen every time)  Everyone in the group has deleted the thread, we've all toggled imessage on/off etc.  There still hasn't been a solution.
    Any help would be appreciated.
    Thanks

  • Reply to all using ItemReply does not work when specifying messageid

    Hello everyone,
    I am trying to use the ItemReply token to perform a "Reply to All"
    action on a mail item with a known message identifier and include the
    original message text in the response. According to the documentation,
    the call should be:
    ItemReply(7;1;"message-id")
    Still, when I execute this token, apparently only a normal reply action
    is performed because only the original sender is listed as recipient.
    (The message text is properly included)
    However, when I manually select the message in the GroupWise client
    first and then execute the same call without specifying the message id,
    all recipients of the original mail are listed in "To:" as expected:
    ItemReply(7;1)
    Could it be that the "ReplyTo" parameter is ignored or does not work
    when a message id is specified as parameter? (Setting "IncludeText" to 0
    does not change anything)
    Thanks in advance and best regards,
    Peter Hofer

    Worth bumping this message. I find the exact same behaviour as mentioned 5 years ago. Using both GW8 and GW2012.
    According documentation, when MessageId is not specified it defaults to the command ItemReplyOpenItem(). I assume that the reason "Reply To all" works without a MessageID is because of that. Someone needs to give a look to ItemReply().

  • Default account setting in Outlook 2010 does not work when composing new messages?

    Hello,
    I am currently using Outlook 2010 (not beta). I have two accounts, a google imap account and a pop3 account.  I have designated my IMAP account as my default account.  As I understand it, this means that when I create a new email,
    it should default to being sent from my IMAP account.  However, whenever I create a new email, it defaults to the account which I am currently viewing in Outlook.  In other words, if I am currently viewing the pop3 inbox, when I compose an email,
    it will default send from that account.  Conversely, when I compose an email while viewing the IMAP inbox, it will default send from that account. 
    Any ideas as to what is going on?  This is rather frustrating because I only rarely send with my pop3 account--only when replying/forwarding email received with that account or other unique situations.  Is there a way to make Outlook be true to
    sending from the default account, without doing something drastic like disabling the secondary account?
    Thanks in advance.
    Rom

    Of course it's a bug.
    Computing Dictionary
    bug definition
    programming 
     An unwanted and unintended property of a program or piece ofhardware, especially one that causes it to malfunction.
    The behaviour itself may be considered a feature by Microsoft, though I disagree, but the fact that one thinks one is specifying a "default" account that is not then used as the default in all cases is clearly a bug.
    It is astonishing to me that in the plethora of options, advanced options and advanced advanced options there is not a checkbox to enable this new behaviour with the default being unchecked.
    Microsoft does it again.

  • Urls do not work when I compose messages

    My links do not work when I drag a website url to my new message or type it in (beginning with http). I can always click on links that I get from others but my links do not seem to "convert" when I send them out. There is an exception, my webpage signature always works.

    Welcome To  Discussions charmarsh!
    You may find the tips linked to below helpful.
    How To Post A Link/URL In Apple Discussions
    How To Create A Link To A Post Within A Thread
    Have Fun!
    ali b

  • PDF loaded using ActiveX will not load when the executable is used on another computer

    Hello,
    I am fairly new to Labveiw and have created a CAN diagnostic tool which uses an ActiveX control to display the CAN Spec PDF on the front panel. This works absolutely fine and still works fine when I create and use an executable on the same computer. However, I need to use the application on multiple computers that do not have Labview installed, and therefore require the executable. I have tried placing a copy of the PDF in the "Volume" folder and recreating the .exe with that path, then placing it in the same location on another computer, but no luck. I am fairly certain it has to do with the static file path, set in the Main VI, since it refers to a static location that does not necessarily exist on the next computer. I need some way to get around this though, so that I can easily transfer the application from one computer to another. The code I am using is very simple; I just open Adobe Reader and the file during initialization then close the reference path (see attached picture). Any Ideas?
    Thank you for your assistance!
    -Mike
    Attachments:
    ActiveX_pdf_code.jpg ‏23 KB

    A solution that I have found to work well is to use the Project Directory node as a root path. In the development environment this node will always return the path to the directory containing the project that is calling it. In an executable, it returns the path to where the executable is located. 
    With that known starting point, I can put files like that pdf in either the same directory as the project/executable or a subdirectory of that location and I can always find it.
    When creating a build spec you can include non-LV files and specify destinations for them. Likewise, the installer will then put these files where they belong during the installation.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Filter using "List" is not working when Exporting Data

    Hi All,
    We have built a BI publisher report with 10 different layouts, each layout is corresponds to one separate report. In one layout we have one table view and "List" tool bar to select the required data. When we select a particular value in the list, the report correctly displays data of the selected value. But when we export this data to an excel sheet, it downloads the entire data irrespective of the selected value into the excel. Is there any way to export only the selected data?
    E.g.
    Consider we have a list for Year which has 4 years as values.
    2008
    2009
    2010
    2011
    When we click on 2008, the report in interactive mode displays the values w.r.t 2008 but when we export it to excel, we see the data of all four years.
    Appreciate your support in advance.
    Thanks,
    Karthick

    Hello All,
    Anyone came across the above scenario? Please advise.
    Thanks.

  • Graphics generated using awt.graphics not displaying when run through a jar

    I've created a small application that works fine when compiled and ran normally.
    When I create a jar and run it, the application works mostly fine too, the button (there's a button in it) shows up, but the graphics produced with java.awt.Graphics don't. What's really weird is that this problem only seems to occur for some people. I sent the jar to some friends and for some of them it worked fine, while others had the same problem I have.
    Can anyone tell me what's causing this and what I can do to fix it?

    I would investigate by finding out what JRE versions are running on each of the users machines and then compare to see if there is a correlation between certain versions and this Graphics problem.

  • HT201303 How do I  verify my account to use apple tv not working when I put in my account details

    I need to verify my payment purchases information in order to use my apple tv.  please assist. Merry xmas
    j

    Exactly as the instructions say to.  Enter the information requested on ATV.  If you have passed that screen you can verify the info in iTunes.

  • If I turn off iMessages on my iphone 5 and only use SMS, I am hoping this will this stop ALL my messages going to partners ipad? I only want 2 use SMS and not have any of my messages go to partners ipad so dont want to alter ipad settings.

    My situtation is this, my soon to be ex previously set up an ipad with both our numbers and we share a linked itunes/icloud account so if my phone is off he gets all my messages via his ipad that I DO NOT have access to his ipad at ALL. I can't set up my own itunes account (not yet until I leave him) otherwise he will know I am leaving him and it will cause major problems. So I was hoping that if I turn off iMessages on my iphone 5 and just talk to my family via SMS and NOT touch his precious ipad mini, that he wont be able to get my messages anymore and if I turn off iCloud storage and back up as well on my iphone only. Is this correct? Its just a temporary solution I am hoping. I have searched for days and hours and I just cant find this answer anywhere....
    Do I HAVE to turn off my phone number off or delete it on his ipad? I am really hoping I can just do this at my own end and not touch his ipad in anyway or have to change my itunes id YET. Once I leave him shortly, I will create a whole new ID etc.  I just wanna know if I can do this myself on my iphone only. Please any experienced help would be greatly appreciated. Thank you so very much.

    mazwig wrote:
    I just want to know if I turn off iMessages and iCloud Back up, and ONLY use SMS myself and my family just SMS's me - and do this on my PHONE ONLY and not touch his ipad (so he doesn't know), if he will get any of my messages I send or receive on his ipad please. Its just a temp thing and I just want to take action myself on my own phone and want to know if this will work. Does anyone know?
    SMS messages will not go to the iPad Mini. It's not capable of receving them. If you have access and can do it without it causing a problem, remove your iPhone from the Apple ID Support profile:
    Go to: https://supportprofile.apple.com/MySupportProfile.do
    Log in if not already logged in.
    Click on "Edit Products"
    Click on the "X" to the right of the product.
    Click "Unregister"
    If anyone in your family uses iMessage, they will go to both you and your boyfriend unless you do that.
    To be completely safe, you may want to simply use an alternate message app such as Skype, Viber, Whatsapp (assuming everyone has a smartphone) until the issue is resolved. Google Voice will also allow you to send and receive texts to another number on your phone.
    Best of luck.

  • Conky new_mails not updating when local mail messages are read

    Apologies if this is the wrong place to ask this, but I'm new.
    I recently installed Arch Linux on my eeePC 1005HA laptop with dwm, conky, and postfix (I followed the wiki to install postfix to send local mail).  I'm using xsetroot to replace the "dwm-5.2" text in the upper right corner with conky-provided information about time, CPU usage, etc., and want to use it to see how many unread local mail messages are in my /var/mail/spool/USER spool.  Using ${new_mails} seems to be the way to go, but the value reported by ${new_mails} only ever increases when a message is sent to the spool, never decreasing when new messages are read or deleted until conky is restarted.  I'm only using the "mail" program to send and receive mail to the local spool for system notifications like "your battery is low, save things now".
    I've seen other users use ${new_mails} apparently fine, but googling for this problem shows other people having a similar problem.  However, I haven't found any forum, wiki, or article about how to fix this without using messy workarounds, and the conky IRC channel didn't know how to fix this, though they've heard of similar problems with mutt.  Any ideas?

    Bump!  I've tried reinstalling conky and postfix/mail, and not much seems to work.  Is conky passé now in favor of something else?

  • Is there a way to use color and other fonts when emailing or messages that isn't a hassle?

    I would think that people are bored of same font and downloading from other app copy and paste is not ideal plus I want to add color to messages to signify importance of statement. Am I not finding an easy method? After all the emoji was added directly to keyboard, why can't it be that easy?

    It's generally better to stick to plain text for email. Depending on the device an email gets read on, all that fancy formatting can look terrible or render the email unreadable.  It can also slow the downloading of an email to a mobile device. Do your recipients a favor and don't weight your emails down.
    Best of luck.

  • Field not updating when switching fields.

    I am using Oracle Forms Builder 10g and I created a procedure to get the data from a related table into the data block
    PROCEDURE GET_MODEL_VAL IS
    CURSOR MODEL_VAL IS
    SELECT VMODEL_NAME
    FROM VEHICLE, VEHICLE_MODEL
    WHERE :VEHICLE.VEHICLE_ID = VEHICLE.VEHICLE_ID
    AND :VEHICLE.VMODEL_ID = VEHICLE_MODEL.VMODEL_ID;
    BEGIN
      OPEN MODEL_VAL;
      FETCH MODEL_VAL INTO
      :VEHICLE.VMODEL_NAME;
      IF MODEL_VAL %NOTFOUND THEN
           :VEHICLE.VMODEL_NAME := NULL;
      END IF;
      CLOSE MODEL_VAL;
      EXCEPTION
           WHEN NO_DATA_FOUND THEN
           MESSAGE ('Model Data Not Found');
           WHEN OTHERS THEN
           MESSAGE ('Post-Query Unsuccessful');
    END;And I created an on validate trigger to check if the FK is valid and then call the above pcedure
    DECLARE
         NUM NUMBER;
    BEGIN
         SELECT COUNT(*) INTO NUM
         FROM VEHICLE, VEHICLE_MODEL
         WHERE :VEHICLE.VMODEL_ID =  VEHICLE_MODEL.VMODEL_ID;
         IF
              NUM = 0 THEN
              DISPLAY_VMID_ALERT;
              RAISE FORM_TRIGGER_FAILURE;
         END IF;
         GET_MODEL_VAL;
    END;Now here's the fun part. If I am updating the record when I tab or click away from the VMODEL_ID field the VMODEL_NAME field updates and everything is fine, however during an insert it does not.
    Any insight?
    The Oracle Peon...
    Edited by: Oracle Peon on Apr 25, 2013 10:18 AM
    Edited by: Oracle Peon on Apr 25, 2013 10:31 AM
    Edited by: Oracle Peon on Apr 25, 2013 11:25 AM

    I was just typing up a response to you Steve when it hit me, the VEHICLE_ID isn't in the database yet during an insert.
    WHERE :VEHICLE.VEHICLE_ID = VEHICLE.VEHICLE_ID
    AND :VEHICLE.VMODEL_ID = VEHICLE_MODEL.VMODEL_ID;should be
    WHERE :VEHICLE.VMODEL_ID = VEHICLE_MODEL.VMODEL_ID;Now I'm a bit new to Oracle so excuse my ignorance but you and Amatu lost me in your explanation.
    I'm going to mark this as answered but I'd appreciate either a little more detail on what you guys did answer or some links to help me learn a bit more.
    Thanks...
    The Oracle Peon...
    Edited by: Oracle Peon on Apr 25, 2013 11:25 AM

  • Is my installaton of CF MX 7 using JVM or not?

    I was recently directed to start using some "global logon"
    software with my application on our company intranet. I don't know
    if it is developed in-house or purchased.
    When I talked to the person providing the software, he asked
    if I was running "Windows and Coldfusion without JVM" or
    "Coldfusion on Windows (using JVM)". I wrote it this way because
    that is the way he asked it. Unfortunately, I didn't know the
    answer to the question. That's not my expertise. We talked for a
    while and he decided I needed his version for "without JVM".
    I've been working with the software for a couple of weeks now
    and it works, but only partially. It uses a cookie to provide
    security information back to the application, then the application
    is supposed to decrypt the cookie and get various pieces of info
    about the user. I'm only getting a small part of the information.
    I'm trying to get more information to determine if he sent me
    the wrong version. How would I find out if I'm using JVM or not?
    When I look in the CF Admin module at the "Java and JVM" tab, I see
    the installation path for JVM is "E:/CFusionMX7/runtime/jre" and
    some "JVM arguments" in a lower box. When I look in the "jre"
    subdirectory, I find subdirectories for bin, lib, and javaws plus a
    bunch of "License" files.
    I'm out of ideas to "fix" the software so I'm wondering if
    they sent the wrong one. Before you ask, I've already been on the
    phone with the provider and the tech support people with no help
    (obviously).
    The server is running Windows server 2003, IIS, MySQL, and CF
    MX 7.
    TIA

    quote:
    Originally posted by:
    Ian Skinner
    Yes ColdFusion 5 and earlier where written in C and thus do
    not use a
    JVM at all and ColdFusion 6 and latter are written Java and
    always use a
    JVM. But that JVM can be subsumed inside of the ColdFusion
    application
    and thus only available for use by ColdFusion or it can be
    installed
    independently of ColdFusion and is thus available for use by
    other
    Java|JSP applications.
    In other words the question is are you using either the
    Standard or
    Enterprise ColdFusion in Stand-Alone mode which embed the JVM
    into the
    ColdFusion installation. Or are you using Enterprise in
    Multi-Home or
    J2EE which install the JVM independently of ColdFusion and
    can be used
    by other applications.
    CF, whether installed in Server configuration or Multiserver
    configuration, uses a JVM included with CF. In either of these
    configurations, JRun is also used as the J2EE application server
    that the CF web app is deployed on. The only difference between
    these 2 is this:
    * In Server configuration, CF is installed with a
    stripped-down JRun designed to run nothing but the CF web app. You
    can't deploy other J2EE web apps, nor do you have access to the
    full JRun install. In this configuration, the JVM used to run the
    stripped-down JRun (and thus the CF web app) is installed at
    {CF_Install_Root}/runtime/jre.
    * In Multiserver configuration, JRun is installed, then CF
    is deployed as a web app on the full JRun install. You can deploy
    other J2EE web apps on this JRun install as well as change/access
    whatever you'd like within JRun. The JVM included with the full
    JRun install and used to run it, and thus the CF web app, is
    installed at {JRun_Install_Root}/jre
    CF, installed using J2EE configuration, is nothing more than
    a web app (.war) that needs to be deployed on your
    already-installed J2EE server.
    The wording you use makes me think you confuse JVM with J2EE
    app server. Especially this sentence:
    "But that JVM can be subsumed inside of the ColdFusion
    application
    and thus only available for use by ColdFusion or it can be
    installed
    independently of ColdFusion and is thus available for use by
    other
    Java|JSP applications."
    Replacing JVM with J2EE app server makes that sentence more
    accurate.
    The J2EE configuration doesn't install a JVM at all. It
    simply packages up a .war/.ear file for you to deploy on your own
    J2EE app server.

Maybe you are looking for

  • Updating Oracle BLOBs through Tomcat's DBCP

    Hi, I've been using Tomcat's DBCP and I'm trying to cast my ResultSet to an OracleResultSet so I can use the getBLOB message. I've searched and realized I had to take part of it out of the wrapper, so I got the connection out of the wrapper using: co

  • Disabling buttons in sequence before using

    Hi Everyone I am new to Adobe captivate. I have put together a program for the company i work for but am getting stuck on a certain item. I have a slide with approx 10 buttons that navigate to other slides. This is successful, but i want to force the

  • Auto Refresh XML Iview

    Hi, I created an xml iview that pulls in Yahoo stock quotes for our company. The iview works fine. Where do I set a property that tells the iview to auto refresh? I have not been able to find that. Our environment is NW04 Stack 11. Thanks, Kris

  • Need help in POI plugin in java

    Hi, I am doing a monthly status report using POI plug-in. Now i am having problem: for example to SUM the cells to one cell: Example : A1=SUM(A2+A3) ( its working fine) but if i do SUM for more cells using " : " this caracter its not working :( =SUM(

  • Patch level mis-match

    we are installing a new server and we want to import clients from the old server to the new one. the problem is that the client copying is failed and it seems the reason is due to patch levels mismatch.    these are the new server patches. SAP_BASIS