Some methods are displaying the result on the server instead on the client.

When I test (form SeatReservationClient class) the method sri.showReservations() located in SeatReservationClient class the results are being displayed on the server side instead on the client but the method sri.numReservations() is displaying the result as i want it i.e. on the client. Please can anyone help me (as always on this forum) find a solution to this problem and display the results correctly?
I have 5 classes:
Interface
public interface SeatReservationInterface extends java.rmi.Remote
     public boolean isReserved(int row, int seat) throws java.rmi.RemoteException;
     public boolean reserve(int row, int seat) throws java.rmi.RemoteException;
     public boolean cancel(int row, int seat) throws java.rmi.RemoteException;
     public int numReservations() throws java.rmi.RemoteException;
public void showReservations() throws java.rmi.RemoteException;
Implementation
public class SeatReservationImpl extends java.rmi.server.UnicastRemoteObject implements SeatReservationInterface
     private Seat[][] theatre;
     * Implementations must have an explicit constructor in order to declare the RemoteException
     * exception.
    * Theatre constructor makes a new movie theatre with numRows rows and numSeats
    * seats (chairs) in each row. All seats are unreserved (unoccupied) in the beginning.
    public SeatReservationImpl(int numRows, int numSeats) throws java.rmi.RemoteException
          theatre = new Seat[numRows][numSeats];
          for(int row = 0; row <theatre.length; row++)
          for(int col = 0; col<theatre[row].length; col++)
          theatre[row][col] = new Seat();
    * The method returns true if the seat at location (row, seat) is reserved.
    * The method returns false in all other cases.
    * Be careful that row numbers run from 1 to numRows, and seat numbers from
    * 1 to numSeats.
     public boolean isReserved(int row, int seat) throws java.rmi.RemoteException
         return theatre[row-1][seat-1].isOccupied();
    * Books the seat at location (row, seat) and returns true if that seat is available.
    * Returns false if that seat is already reserved.
     public boolean reserve(int row, int seat) throws java.rmi.RemoteException
          return theatre[row-1][seat-1].occupy();
    * Cancels a seat reservation at location (row, seat) is that seat was booked, and returns
    * true in that case. The method returns false if that seat had not been reserved.
     public boolean cancel(int row, int seat) throws java.rmi.RemoteException
          return theatre[row-1][seat-1].release();
    * Returns the number of reserved seats.
     public int numReservations() throws java.rmi.RemoteException
          int count = 0;
          for(int i = 0; i < theatre.length; i++)
          for(int j = 0; j < theatre[j].length; j++)
          if(theatre[i][j].isOccupied())
          count++;
          return count;
* Prints an overview over all reservations. Reserved seats are shown as "*", available seats
* as "-". For each row the row number is shown, then a couple of blanks, and then the
* reservations. An example is
* 8 -----****----
* 7 ---**---**---
* 6 ----***------
* 5 -------------
* 4 -------------
* 3 ----------***
* 2 **-------
* 1 -------------
public void showReservations() throws java.rmi.RemoteException
          for(int row = theatre.length-1; row>=0; row--)
               System.out.print((row+1) + "\t");
               for(int j = 0; j<theatre[row].length; j++)
               if(theatre[row][j].isFree())
               System.out.print("-");
               else
               System.out.print("*");
               System.out.println();
          return;
[i]Server import java.rmi.Naming;
public class SeatReservationServer
public SeatReservationServer()
try
     SeatReservationInterface sri = new SeatReservationImpl(10, 5);
     Naming.rebind("rmi://localhost:1099/SeatReservationService", sri);
catch (Exception e)
System.out.println("Trouble: " + e);
public static void main(String args[])
new SeatReservationServer();
Client
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
public class SeatReservationClient
    public static void main(String[] args)
        try
               SeatReservationInterface sri = (SeatReservationInterface) Naming.lookup("rmi://localhost/SeatReservationService");
               /* Make two reservations */
               System.out.println("Reservations:");
               System.out.println("1,2");
               System.out.println("1.3");
               System.out.println("1,4");
               sri.reserve(1,2);
               sri.reserve(1,3);
               sri.reserve(1,4);
               System.out.println("The Seat is occupied - " + sri.isReserved(1,2));
               System.out.println("The Seat is occupied - " + sri.isReserved(1,3));
               System.out.println("The Seat is occupied - " + sri.isReserved(1,4));
               /* Show the theatre */
               sri.showReservations();
               /* Release a seat that had been booked */
               System.out.println("Release seat row 1 seat 2");
               sri.cancel(1,2);
               System.out.println("The Seat is occupied - " + sri.isReserved(1,2));
               /* Show the number of total reservations and the theatre */
               System.out.println("Number of reservations: " + sri.numReservations());
               sri.showReservations();
        catch (MalformedURLException murle)
            System.out.println();
            System.out.println("MalformedURLException");
            System.out.println(murle);
        catch (RemoteException re)
            System.out.println();
            System.out.println("RemoteException");
            System.out.println(re);
        catch (NotBoundException nbe)
            System.out.println();
            System.out.println("NotBoundException");
            System.out.println(nbe);
        catch (java.lang.ArithmeticException ae)
            System.out.println();
            System.out.println("java.lang.ArithmeticException");
            System.out.println(ae);
Class containing instance methods
public class Seat
private boolean occupied;
     * Constructors:
     Seat()
     Seat(boolean o)
          occupied = o;
     * Instance methods:
     public boolean isFree()
          return !this.occupied;
     public boolean isOccupied()
          return this.occupied;
     public boolean occupy()
          if(occupied)
          return false;
          else
               occupied = true;
               return true;
     public boolean release()
          if(!isOccupied())
          return false;
          else
          occupied = false;
          return true;
}

Your code is working as expected. The server executes System.out.println in showReservations() and this comes out on the server console. The client executes System.out.println() after calling numReservations and this comes out at the client. Any other expectations are misplaced.

Similar Messages

  • HT1338 When I email an attachment with "Always Sent Windows-Friendly Attachments" checked, the result is a picture embedded in the body of the email, not a attachment.  What am I doing wrong.

    When I email an attachment (a .jpg file) with "Always Send Windows-Friendly Attachments" checked, the result is a picture embedded in the body of the email, not a attachment.  What am I doing wrong.

    1. "Always Send Windows-Friendly Attachments" has nothing to do with the display of attachments on either your machine or other ones. It's an esoteric setting that strips the resource fork from Mac files (that might have them) which could apper as a duplicate file on the Windows machine.
    2. Send Plain Text emails. Then it will always be received as an attachment.

  • Returning the result of a database query to a client

    glassfish
    JAX-WS 2.0
    NetBeans 5.5
    Is it possible to send a CachedRowSet object to a client?
    I get an error when i try to do so. (I can't deploy the web service method that returns the CachedRowSet)
    Is there a better way to return the result of database query to a client?
    I'd appreciate any suggestions or sample code.

    Hi!
    The result of this query will be the max ID of users' IDs.
    Let say we have:
    String sql="select max(users.id) from users";
    Statement st = ctx.conn.createStatement();
    ResultSet rs = st.executeQuery(sql);
    rs.next();     
    So you can get the max Id in the following way:     
    int maxId=rs.getInt("id");
    Regards,
    Rossi

  • How do i keep the results from a formula but delete the original data

    I want to delete the column of original data and only keep the results.

    Hi rdavidland,
    Select and copy the cells that contain the formula.
    Menu > Edit > Paste Formula Results.
    Delete the original data.
    Regards,
    Ian.

  • How do I change the default program to open Pages docs to the old (4.3) version instead of the new one (5.0)?

    How do I change the default program to open Pages docs to the old (4.3) version instead of the new one (5.0)? When I do what Apple said and go to a Pages file in finder and select "get info" then select "Pages 4.3" and "change all" it just defaults to the new one even though I'd selected the old one. Do I need to completely uninstall the new version of Pages or is there another work around because the new version of Pages comes dreadfully short of the features I need that are included in the old one?

    Eric Kraft wrote:
    HOWEVER, if you modified a document in 5.0, 4.3 can't open it. You'll have to use Time Machine to replace the modified version with an earlier version that was last modified in 4.3.
    Actually there is a workaround.
    If you open the file in Pages 5, it can then be exported on Pages 0.9 format to another folder. I had to do this as the document was only in iCloud and couldn't be recoverd by Time Machine.
    Worked for me!

  • The Web application at could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application

    Hi,
    I have created on windows service to fetch sharepoint list ad update the list items.
    when i run this service in sharepoint server(where the sharepoint site is hosted),it is working fine. If i run the same service in another machine(sharepoint installed in this machine also). it is giving the below error
    The Web application at [URL] could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
    Code snippet
    SPSite sharepointSite = null;
                SPWeb rootWeb = null;
                try
                    //SPList current = null, previous = null;
                    string colmId = ConfigurationManager.AppSettings[ID_COLM];
                    List<TaskEntity> list = new List<TaskEntity>();
                    sharepointSite = new SPSite(URL);
                    rootWeb = sharepointSite.OpenWeb();
                    SPList current = rootWeb.Lists[ConfigurationManager.AppSettings[OMEGA_REGISTRATION_LIST]];
                    WriteEventLog("current" + current.Items.Count.ToString());
                catch (Exception ex)
                    ExceptionMethod(ex);
                finally
                    sharepointSite = null;
                    rootWeb = null;
    I have pointed .net framework to 3.5 version and target palform as Any CPU. Please suggest me

    Hi mallela1,
    I also had similar issue couple of months back when I was trying to access a remote URL from a Windows service when the site does not exists in the server where service resides.
    You cannot access a remote url (even though it is SharePoint server and also in same network ) from server object model.
    SPSite can look in the current server only. here what is happening is SPSite will look for this in the current server DB and it is not finding this errror.
    So please dont use ServerObject model for accessing remote sites. You can use Client Object model for the code /requirement you have stated above.
    I wasted lot of time in finding a work around to make to work. It did not. So look for other options.
    Regards,
    Nandini

  • When I have finished working on an image in Photoshop and I hit the save button it goes instead to the "save as" screen. This never happened in previous Photoshop versions. When I get to Lightroom, I have a grey screen the says "File could not be found."

    When I have finished working on an image in Photoshop and I hit the "save" button, it goes instead to the "save as" screen. This never happened in previous Photoshop versions. When I get to Lightroom, I have a grey screen the says "File could not be found." I then have to go to "locate" to get the image. When I select the correct image, I get a message that it is not the same file name but I am eventually able to access the image. Needless to say this is having a negative impact on workflow!

    The problem with write permissions for the OneDrive folder only shows up in Lightroom 6's export dialogue, that's why it's to irritating. Lightroom 5.7.1 is not having that problem nor does the file explorer. The problem also exists on both of my machines. I will try to check for other problems with the OneDrive troubleshooter though: Running the OneDrive troubleshooter - Windows Help   

  • What do i do when i go to charge my ipod and the apple logo shows up instead of the low-battery icon?

    what do i do when i go to charge my ipod and the apple logo shows up instead of the low-battery icon?

    Try resetting.
    Press and hold the On/Off Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears.

  • I currently have a mac osx, and my CC keeps coming saying its expired, when it should be running the CS6 design standard.  So how do I get my platform to use the CS6 as my default instead of the CC one.

    I currently have a mac osx, and my CC keeps coming saying its expired, when it should be running the CS6 design standard.  So how do I get my platform to use the CS6 as my default instead of the CC one.

    Sign in, activation, or connection errors | CS5.5 and later
    And you can change the default program for a file type under File --> Info.
    Mylenium

  • HT5096 how about copying the backup to a server instead of a hard drive?

    how about copying the backup to a server instead of a hard drive? Doesn't seem to work.

    ISP's cap your upload speed to a fraction of your download so you don't run a server off your computer.
    You can certainly spend more money to upload faster, but it's a waste of money and the data online can vanish or be held or spied upon.
    Then there is a prolem that you want to restore your system and there is slow Internet.
    Apple now requires fresh OS X installs to come from them online, it's better to have local drive to boot from anytime, so a bootable clone is ideal, better than TimeMachine which is only a backup system
    Most commonly used backup methods

  • I have puschased songs on itunes, some songs are not completed songs, is this itunes error or the artist produced uncompleted songs?

    album: Univeral Religion Chapter 5
    song # 5: Falling Away (Armin Van Buuren remix), artist: Hannah
    album: A state fo Trance Yearmix 2011 (mix by Armin Van Buuren)
    song# 20: Be your sound, artist Cosmic Gate & Emma Hewitt
    song#10: Keep Waiting(Orjan Nilsen Midsumernite remix), artist: Tiddey
    I have noticed these songs are not completed songs.  Can you guys check if your songs that post on itunes store are good ripped.  After i redownloaded and listened to these songs are still not completed songs. 
    Thank You

    Were the songs in question downloaded directly on the device or synced from iTunes on the computer?
    Content does not magically appear on the device.

  • Can't get the result if I use SUBSTR From the resultSet

    Hi,
    I have a request that make some changes on a String data.
    This modification is an extraction of a sub string with SUBSTR function of oracle.
    The problem is that I can to get the result on my java code
                   pst = connect.prepareStatement(GET_PATH);
                   rset = pst.executeQuery();
              while (rset.next()) {
                   String chemin = rset.getString("IMG_PATH"); // rset.getString(2);
                   system.out.println("Le chemin récuperé de la base est : " + chemin);
                   chemins.add(chemin);
              }this is the request :
    SELECT DISTINCT nl.img_id, SUBSTR(ni.img_chemin, 1, INSTR(ni.img_chemin, '\', -1)) IMG_CHEMIN from images nlThe oracle documentation say the SUBSTR function return a STRING type.
    Thnaks for your help. (And sorry for my little english)
    Technical Information :
    DB : ORACLE
    DRIVER VERSION : ojdbc14-10.2.0.3.0.jar (tested with version 9 same thing)
    Java 6 update 3
    Edited by: Aberghouss on 29 août 2008 17:11

    Aberghouss wrote:
    Hi,
    I change the INSTR(ni.img_chemin, '\', -1) by number 20 and the program get correctelly the value
    SELECT DISTINCT nl.img_id, SUBSTR(ni.img_chemin, 1, 20) IMG_CHEMIN from images nlNow have you any idea how can I resolve this problem with INSTRLittle confusing what you are actually doing.
    You need to post code that actually has the problem.
    Given that you are using names, rather than indexes, usually the problem is that the name doesn't match what is actually in the meta data. Try printing the meta data. And try using indexes just to verify that there is in fact a result (which would be another reason for not getting it.)

  • Splitting out string, using the results to lookup reference, then returning the reference name as a string?

    I have a field that contains a comma separated string of sys_id’s that relate to another table.
    I am trying to write a query that returns the name value from the reference table, so that the result is a comma separated string of the name field.
    Can anyone help with the SQL required to split out the sys_id’s, do the look-up and return the names back into a string?
    Table1
    Number
    Category
    1001
    Sys_id1, Sys_id3, Sys_id9
    1002
    Sys_id3
    1003
    Sys_id4,Sys_3
    1004
    Sys_id1, Sys_id9, Sys_id10, Sys_id6
    Category Reference Table
    Category Sys_id
    Category_Name
    Sys_id1
    Consulting
    Sys_id3
    Negotiate
    Sys_id4
    Planning
    Sys_id6
    Building
    Sys_id9
    Receipt
    Sys_id10
    Complete
    The result I am looking for would be.
    Number
    Category
    1001
    Consulting, Negotiate, Receipt
    1002
    Negotiate
    1003
    Planning, Negotiate
    1004
    Consulting, Receipt, Complete, Building

    I am not going to arguee regarding your model, but you should consider normalizing it.
    The idea is to have a function to split the string and return a row for each element in the list. Dump the result into a table and then use FOR XML PATH to do the string aggregation.
    To learn about different methods you could use to create the split function refer to this article.
    Arrays and Lists in SQL Server
    http://www.sommarskog.se/arrays-in-sql.html
    Here is an example using XML methods. This is just an example and it doesn't deal with proper indexing, weird characters as part of the list that can't be translated as xml, etc.
    SET NOCOUNT ON;
    USE tempdb;
    GO
    DECLARE @T TABLE (
    Number int,
    Category varchar(50)
    INSERT INTO @T (Number, Category)
    VALUES
    (1001, 'Sys_id1, Sys_id3, Sys_id9'),
    (1002, 'Sys_id3'),
    (1003, 'Sys_id4, Sys_id3'),
    (1004, 'Sys_id1, Sys_id9, Sys_id10, Sys_id6');
    DECLARE @R TABLE (
    Sys_id varchar(15),
    Category_Name varchar(35)
    INSERT INTO @R (Sys_id, Category_Name)
    VALUES
    ('Sys_id1', 'Consulting'),
    ('Sys_id3', 'Negotiate'),
    ('Sys_id4', 'Planning'),
    ('Sys_id6', 'Building'),
    ('Sys_id9', 'Receipt'),
    ('Sys_id10', ' Complete');
    DECLARE @W TABLE (
    Number int,
    pos int,
    Sys_id varchar(15),
    PRIMARY KEY (Number, Sys_id)
    INSERT INTO @W (Number, pos, Sys_id)
    SELECT
    A.Number,
    ROW_NUMBER() OVER(PARTITION BY A.Number ORDER BY N.x) AS pos,
    N.x.value('(text())[1]', 'varchar(15)') AS Sys_id
    FROM
    @T AS A
    CROSS APPLY
    (SELECT A.Category AS [text()] FOR XML PATH('')) AS B(c)
    CROSS APPLY
    (SELECT CAST('<l>' + REPLACE(B.c, ', ', '</l><l>') + '</l>' AS xml)) AS C(x)
    CROSS APPLY
    C.x.nodes('/l') AS N(x);
    SELECT
    A.Number,
    STUFF(
    SELECT
    ', ' + C.Category_Name
    FROM
    @W AS B
    INNER JOIN
    @R AS C
    ON C.Sys_id = B.Sys_id
    WHERE
    B.Number = A.Number
    ORDER BY
    B.pos
    FOR XML PATH(''), TYPE
    ).value('(text())[1]', 'varchar(MAX)'), 1, 2, '') AS Category
    FROM
    @T AS A;
    GO
    AMB
    Some guidelines for posting questions...

  • How Can I speed  up the results on my JSP page with the help of Caching.

    I am generating a dropdown listbox by merging an xml file with a style sheet(xsl).
    This list box comes up fine without any problems. Now, I am adding some advanced
    logic to the
    style sheet (xsl) to use the same xml file in a more efficient way. This time
    the generation
    of the list box is taking much longer (upto 25 seconds) although I get the results
    I want.
    Is there any way I could speedup this process by using weblogics caching. I know
    the process is slowing down
    due to the code in the stylesheet. Will caching resolve this issue?. I tried
    using
    <wl:cache> </wl:cache> on the jsp page generating this listbox but found no improvement.
    Any help will be very much appreciated.

    turn off your phone, unplug your router, leace it off for 30 seconds, and then power it back on and turn the iphone back on

  • Looking to set the result of a variable based on the content of another (new to scripts)

    Hi,
    I'm new to scripts, new to acrobat forms to be honest, so be gentle with me
    I have a text field Acc1pnt which can accept either Y or N as an entry. Based on the answer, text field Acc1snd would always be N/A if the result of Acc1pnt is N. I'm looking for a script that will add N/A to the second text field and skip over it (make read only?) if the answer to the first field is N.
    Sorry if I'm making this look like hard work. Basically a check is made as to whether an accessory is received and, if it is, whether it is 'sound' or 'damaged'. Obviously if it isn't received then it's condition is irrelevant hence N/A in the senond text field.
    Also, is there something simple I can add to convert an entry to a capital letter?
    Thanks in advance
    Cliff

    Hi Gilad
    I've shied away from radio buttons as the users are used to tabbing through the fields and 'clicking' a radio button would mean taking their hands from the keyboard, I will certainly consider it though.
    Acc1snd (the 2nd variable) should be editable ONLY if the answer to Acc1pnt (the 1st variable) is Y. If the value of the 1st variable is N then Acc1snd can only be N/A (not applicable) and should not be editable.
    Obviously if the user makes an initial mistake and needs to change the value of the 1st variable to Y then the 2nd variable would then need to be editable.
    I will run through the tutorials this evening

Maybe you are looking for

  • Anyone know how to delete an app icon bookmark?

    I'm using an iPhone 4 with the 5.1 iOS.  I downloaded an app for LG which turned out to be just a Safari bookmark with an app icon.  It looks like a regular app but when you click it - Safari opens and it takes you to the LG webpage.  Now I want to g

  • Saving Dialog Box - how to save to a folder 3 layers deep

    Finally through the leopard install!! 3 times a charm I know this is a really basic question... but how do you save directly to a folder a few layers deep in my folder set up. I click on file save as.... then click on the "where" drop down box but I

  • External Hard drive suddenly will only read! How can I make it read/write again?

    Hi folks, I'm working with a Seagate FreeAgent GoFlex 320gb External Hard Drive on the imacs here at my university. I have it formatted to ExFAT so that I could use it with my pc as well but I've never had to so far so it's only ever been used on the

  • Livecycle form crashes Reader and Acrobat

    I've created a Livecycle form that has been working great. However, a user managed to corrupt it somehow and now it causes both Reader and Acrobat to freeze and then close when trying to load it. I also tried it in Nuance which causes a freeze but no

  • Cache Refresh Problems:J2EE

    Hi I am facing a problem in cache refresh. The XI 3.0 server is at SP10. Now whenever i am doing any changes in directory and activating it,it doesnt give me any error. but when i am cheking the Cache notifiactions it shows me a "GREEN" light for ABA