Applet on client to help with session invalidation

Dear All,
I have a web application that when run by a user, per request, takes up approximately 40 MB of memory due to massive data structures being created, etc. Obviously, if the user leaves the site and goes elsewhere, I don't want that memory being held, even until the session times out(which I have to set at 30 minutes, due to the user community requests). It was suggested to me to create an applet that is embedded in every JSP page that constantly updates an property in a servlet basically saying "I'm here" and when that property hasn't been updated in N seconds, the servlet will call the invalidate method on the session that's not been updated.
Is this approach feasible? Is there some simpler method I could take to get the same effect? I realize the web is state-less, but I need a work-around in this case to make it act like it is.
Thanks,
Mike Brubaker

You should not need a full-blown applet. You could always use the HTTP meta-refresh tags to request that the browser poll over an interval you specify. The simplest approach would be to open a popup window that has the refresh logic. Place a button there, "logout". You could also have a message, such as, "User [username] has been logged on for [interval]."
Also, consider serializing the 40 mB memory structure to the filesystem. This would work best if the time between requests is relatively longer than in most applications. If the latency of the database routines to generate the 40 mB structure is low, and the interval between requests is relatively high, consider discarding the memory structure after the request has been completed.
- Saish
"My karma ran over your dogma." - Anon

Similar Messages

  • Need help with session sharing in WebCenter Portal

    Hi, How can I share session between a WebCenter Portal application and the portlets it is consuming?
    Basically I want this for authentication. In the portal framework application, I'm setting a user object in the session, How can I get the object in a portlet?
    Regards,
    Navaneet

    IN the second page, you have to make sure that the session
    has been started.
    Put this at the very top of the page -
    <?php if (!isset($_SESSION)) session_start(); ?>
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Alidad" <[email protected]> wrote in
    message
    news:g184i4$jgf$[email protected]..
    > have created a login page (php/mysql) with username and
    password boxes.
    > when
    > the form is submitted the mainpage loads up.
    >
    > i want the main page to be specific to that user, so i
    want their name to
    > appear in the first line. eg.. Welcome back 'David'
    >
    > I read a tutorial in the past that tought me to send the
    users id in the
    > URL
    > and then create a record set on the mainpage that was
    filtered by the URL
    > parameter.
    >
    > I have forgotten how to do this and the tutorial is no
    longer available on
    > Adobe's site.
    >
    > I tried that with
    > $_SESSION['MM_Username'] = $loginUsername; \\ in first
    page then
    > echo $_SESSION["MM_username"]; \\in second page, but
    > the
    > problem is that is not showing user name.
    >
    > i need help with that please!
    >
    > can anyone tell me how to do this? Thanks in advance,
    >
    > AM
    >

  • Need help with session using dreamweaver

    have created a login page (php/mysql) with username and
    password boxes. when the form is submitted the mainpage loads up.
    i want the main page to be specific to that user, so i want
    their name to appear in the first line. eg.. Welcome back 'David'
    I read a tutorial in the past that tought me to send the
    users id in the URL and then create a record set on the mainpage
    that was filtered by the URL parameter.
    I have forgotten how to do this and the tutorial is no longer
    available on Adobe's site.
    I tried that with
    $_SESSION['MM_Username'] = $loginUsername; \\ in first page
    then
    echo $_SESSION["MM_username"]; \\in second page, but the
    problem is that is not showing user name.
    i need help with that please!
    can anyone tell me how to do this? Thanks in advance,
    AM

    IN the second page, you have to make sure that the session
    has been started.
    Put this at the very top of the page -
    <?php if (!isset($_SESSION)) session_start(); ?>
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Alidad" <[email protected]> wrote in
    message
    news:g184i4$jgf$[email protected]..
    > have created a login page (php/mysql) with username and
    password boxes.
    > when
    > the form is submitted the mainpage loads up.
    >
    > i want the main page to be specific to that user, so i
    want their name to
    > appear in the first line. eg.. Welcome back 'David'
    >
    > I read a tutorial in the past that tought me to send the
    users id in the
    > URL
    > and then create a record set on the mainpage that was
    filtered by the URL
    > parameter.
    >
    > I have forgotten how to do this and the tutorial is no
    longer available on
    > Adobe's site.
    >
    > I tried that with
    > $_SESSION['MM_Username'] = $loginUsername; \\ in first
    page then
    > echo $_SESSION["MM_username"]; \\in second page, but
    > the
    > problem is that is not showing user name.
    >
    > i need help with that please!
    >
    > can anyone tell me how to do this? Thanks in advance,
    >
    > AM
    >

  • Can anyone help with an invalid sibling link problem?

    Following the computer not getting through to admin sign up today, I ran Disk Utility from the start up disk. It revealed an invalid sibling link that couldn't be repaired. I've trawled the web for a solution, which had me sign in with single user mode (currently logged in as such).
    In this mode, I did the following:
    Typed umount /dev/disk0s3, which seemed to have the HD mounted on it.
    Typed fsck_hfs -r /dev/disk0s3
    It says: The volume Macintosh HD could not be repaired.
    Q: how do I remount the volume and then safely shut down to get a techie on this? I'm not sure I'm confident enough to fix the problem or attempt to retrieve files with Firewire. The problem computer is a Powerbook G4, the potential target to use as an external hard drive is an imac 7.1.
    I'm not sure if the volume is mounted. If I type 'ds' it lists /dev/disk0s3 as mounted on /
    Whereas devfs is on /dev, fdesc is on /dev and <volfs> is on /.vol. I don't really understand this - a bit out of my depth. I wondered if mount /dev/disk0s3 would remount it?
    Any help appreciated.

    When confronted with an issue that Disk Utility can't fix, most people get Disk Warrior or TechTool Pro may be able to help too. Or you could try wiping the disk clean, writing zero's to the surface, and restore from backup.
    Here's the mount format for 10.5. If you have 10.4 or earlier, you can choose it at the top of the page:  http://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/ 10.5/man8/mount.8.html

  • Help with a Invalid Object

    Hello!
    I have here 6 invalid objects, but 5 are view's and olny this is a procedure that i dont now where i put the INTO that the oracle say me. Somebody can help me?
    the error message is:
    Line # = 51 Column # = 4 Error Text = PLS-00428: an INTO clause is expected in this SELECT statement
    and the SELECT is:
    SELECT clientemp.rut, REPLACE (razon, '''', '') AS RAZON, ultima_boleta.numdoc AS NUMDOC,
    TO_CHAR (ultima_boleta.fecvct, 'dd-mm-yyyy') AS FECHA_ULT,
    SUM (saldo) - NVL (SUM (saldo_cuotas), 0) AS SALDO
    FROM clientemp, cuotas_novencidas, ultima_boleta
    WHERE empresa = '760208701'
    AND sede = 'Santiago'
    AND SALDO > 0
    AND SALDO <= 99999999
    AND cuotas_novencidas.cliente(+) = clientemp.cliente
    AND ultima_boleta.cliente = clientemp.cliente AND LENGTH(clientemp.rut)<10
    GROUP BY clientemp.rut,
    clientemp.cliente,
    REPLACE (razon, '''', ''),
    ultima_boleta.numdoc,
    TO_CHAR (ultima_boleta.fecvct, 'dd-mm-yyyy');
    i allready tryed so many options, but without solution.
    Thanks!

    When I see this error... I could assume that the select statement is inside a PL/SQL block.
    And you might need these columns into the variables. If you have declared the variables, make an "INTO" into those from these columns you are selecting.
    example:
    declare
    num number;
    begin
    select 1 into num from dual;
    dbms_output.put_line(num);
    end;

  • Help with session variable please - CS5.5 PHP

    Hi all,
    I am needing a little assistance with using a session variable and hope that someone may point me in the right direction.
    I have created a PHP page that uses the Dreamweaver 'User Authentication' feature, and the basics of this works fine, directing a user to the correct pages depending on whether they are or are not a valid user. I would like however to personalise the 'valid user' page with the persons Username as entered in the User Authentication table....a seemingly simple task using a session variable, but one that I just don't seem to be able to get working!
    The code generated for the UA on page 1 is as follows:
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['txtfirst_name'])) {
      $loginUsername=$_POST['txtfirst_name'];
      $password=$_POST['txtsurname'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "member_update.php";
      $MM_redirectLoginFailed = "login.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_panto, $panto);
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
       $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;         
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];   
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>
    Firstly, the text highlighted in red above appears to be setting the session variable that I require. Is This correct?
    If so, what is the code that I need to place in page 2 to use that session variable? or
    Do I need to do something else on page 1 to properly assign the session variable?
    Would really appreciate your expertise
    Mark

    It looks as though you've set the columns incorrectly in the User Authentication server behavior. This is the SQL query that checks the user's credentials:
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
    You're looking for firstname and surname, whereas you should be looking for the user's login name and password.
    $_SESSION['MM_Username'] is a session variable that stores the user's login name. To use it in a subsequent page, all that's needed is for the page to begin with session_start(). You can then echo the value to display it.
    If you want to display the person's real name, you need to create a recordset in the second page using $_SESSION['MM_Username'] to find the firstname and surname. Alternatively, you can edit the existing code like this (I've copied only part of it):
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        $row = mysql_fetch_assoc($LoginRS);
         $_SESSION['full_name'] = $row['firstname'] . ' ' . $row['surname'];
        if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
       $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;
    You can then use $_SESSION['full_name'] in a subsequent page that begins with session_start().

  • Can anyone help with an invalid pin on an iTunes card

    I purchased an iTunes card today and i entered the code correctly but a message states that the code is not a valid code. Has any one had problems with this before and how can I fix it? Online support was no help because it wasn't working.

    When confronted with an issue that Disk Utility can't fix, most people get Disk Warrior or TechTool Pro may be able to help too. Or you could try wiping the disk clean, writing zero's to the surface, and restore from backup.
    Here's the mount format for 10.5. If you have 10.4 or earlier, you can choose it at the top of the page:  http://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/ 10.5/man8/mount.8.html

  • Help with session in custom tag

    Hello,
    I want to create a tag that returns true if the session is valid.
    <s:Expired>
    do something
    </s:Expired>
    How do you get the session in a *.java file that is not a servlet?
    I'm new to tags, ans am using JSTL 1.1 and Tomcat 5.0.19
    Thanks
    Frank

    In a custom tag you have a pagecontext object as a member of your class
    with it you can do something like
    HttpServletRequest request = (HttpServletRequest) pageContext.getAttribute(PageContext.REQUEST);
    then it's the usual
    request.getSession()

  • Help with SESSION.Auth.IsLoggedIn

    I have buttons my users click to access password protected
    areas of my site.
    My problem is that everything is working great until the
    session times out, then
    clicking the button with the code below, doesn't throw the
    login popup, but rather
    goes to the page in a full page.
    Any ideas why my code wouldn't throw the popup after the
    SESSION.Auth.IsLoggedIn
    evaluates to false?
    Thanks!
    Rick
    <CFIF IsDefined("SESSION.Auth.IsLoggedIn")>
    <a href="site_docs.cfm" target="_self"
    <cfelseif #CGI.User_Agent# contains "firefox" >
    <a href="site_docs.cfm"
    onclick="NewWindow(this.href,'_blank','400','230','yes');return
    false"
    <cfelse>
    <a href="site_docs.cfm"
    onclick="NewWindow(this.href,'_blank','430','236','yes');return
    false"
    </cfif>

    Michael,
    Thanks for replying.
    I have my button successfully throwing an alert displaying
    the status of the user's login (using Ajax). But I still haven't
    figured out how to access that from my button in a way that allows
    me to direct the user either to a button-specific page or a login
    pop up.
    I need to rewrite the javascript below to do that. And also
    to pass the link in the <a href> that calls the function.
    Otherwise I'll need a separate set of Javascript functions for each
    button!
    HTML page (just to test functionality):
    <html>
    <head>
    <script src="engine.js"></script>
    <script>
    function My_Request(){ http( 'GET' , 'JSMX.cfm' ,
    My_Response ); }
    function My_Response(obj){ alert(obj); }
    </script>
    </head>
    <body>
    <a href="javascript:My_Request();">Click
    Here</a>
    </body>
    </html>
    JSMX.cfm page :
    <cfsetting enableCFoutputOnly="Yes"
    showdebugoutput="No">
    <CFIF IsDefined("SESSION.Auth.IsLoggedIn")>
    <cfset myVar = 1>
    <CFELSE>
    <cfset myVar = 0>
    </CFIF>
    <cfwddx action="CFML2JS" input="The value of myVar is:
    #myVar#" toplevelvariable="anythingwewant">
    Sample link on a button (not working right) I'm doing a
    browser detect here, as the pop up formatting is differently in
    Firefox and IE:
    <cfif #CGI.User_Agent# contains "firefox">
    <a href="javascript:My_Request(site_docs.cfm);"
    onclick="NewWindow(this.href,'_blank','400','230','yes');return
    false"
    <cfelse>
    <a href="javascript:My_Request();" href="site_docs.cfm"
    onclick="NewWindow(this.href,'_blank','430','236','yes');return
    false"
    </cfif>
    OK. Getting closer...
    This JS at least seems to be throwing the correct alert
    depending on LoggedIn status:
    <script>
    function My_Request(){ http( 'GET' , 'JSMX.cfm' ,
    My_Response ); }
    function My_Response(obj){
    if (anythingwewant == 1) {
    alert("do this");
    else
    alert("do that");
    </script>
    Now I still have to figger out how to pass the link in each
    <a href> when I call the function onClick, and do the browser
    check.

  • Can anyone help with "session timed out" at iTunes store?

    I am trying to purchase music from the iTunes store and I am being asked to accept Terms and Conditions to continue which I do - I check the box and I click on accept (immediately). At this point I am told that my session has timed out and to try again. I cannot get past this step, I'd appreciate some advise.  Thank you.

    I used to see that in iOS6 once in a while. Close the apps and reboot the iPad and then look in the apps again. You know how to close the apps so close them first.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Need help with session state/item refresh

    I have an application that allows users to record productivity information for our employees. There are different types of work they have to do, so the form is in header/multiple-detail form and uses collections to handle all processing. In the header portion are the fields that record the time of work. Though this is stored in the database as a single field for start of shift and single field for end of shift, in the entry it is split up into 9 fields: 3 for day, month, and year, and three more each for start hours, start minutes, AM/PM, end hours, end minutes, and AM/PM, which I then concatenate to get the dates to store. The update part works fine. When I go in to display each of these, I have to use an SQL query to retrieve only that section of the time.
    The problem I am having is that if the user pulls up several timecards to edit them, it retains these time values from the previous timecard, and due to the way the collections refresh, I can't seem to get either item session state parameter (Only when Null/Always from Source) to achieve the desired result. If I use the Only When Null option, I retain the values from the previous timecard. If I use the Always from Source, the user can't update any of the time-related input.
    Can anyone suggest a solution? I've tried a session state process that fires on entry to clear those items and ran into the same problem as using the Always From Source option. There has got to be a way to handle this, but it's got me stumped and my users are clamoring for a fix.
    Page initial load
    A. Before Header process populates job collection and other collection (not header info), which comes straight from DB table.
    B. Data displays for Header (from table) and two detail sections (from collections)
    User presses Submit to save changes
    1. On Submit Before Processing: updates job and other collections (to preserve changes in case validation fails)
    2. Validations check to make sure job codes are valid, date is valid, employee is valid, etc.
    3. On Submit After Processing: Writes changes to header from input form, writes changes to job and other from collections to appropriate DB tables
    I also have two On Submit After Processing processes to add blank lines - one for each collection. These are triggered via buttons.

    Blair:
    Does creating a 'before header' process to populate these fields make a difference ? The sql could be something like
    select TO_CHAR(TC_START_TIME,'HH') into :P1115_TIME_IN_HH from TC where TC_ID = :P1115_TC_ID;You should set the 'Source Used' back to 'Only when current value in session is null' and the 'Source Type' to 'Static Assignment(....)' and clear out the 'Source value or expression' field.
    varad

  • Help with session

    I have multiple application running under webapp of my tomact. I have put an index.jsp page in the ROOT folder instead of the tomcat default one. On that page I created a session object, I was now wondering if would be possible to share session accross the different application running under the same tomcat.
    Many thanks,

    well in the index.jsp I have links to other application, so instead of making the user logging in again for different app, have one login store the username in a session object , on each application I want to get the username from the session, to little check, if the access they see the application, if not they get an error page.
    At the moment I getting null from the session.

  • Send message to client before session invalidated

    i am using jsp and java servlet tech. for my web application.
    my problem is :
    i want to send a message to client before session invalidated.
    please help me to find the best way to solve my problem.

    You can detect session termination by putting an object in the session attributes which implements HttpSessionBindingListener. What you can't do is send a message to a client, basically because all http transactions are initiated by the client. The only way I can see you could do this is to put an applet on your web pages which periodically consults the server concerning the session state.
    Then the problem is that there's no obvious way of determining if the session is about to timeout, only whether it has or not. Your applet couldn't return the session cookie (as such) because that would reset the session timeout and the session would never expire. If you could obtain the session without reseting the expiry (perhaps from SessionContext though that's depracated) you could look at getLastAccessedTime() and getMaxInactiveInterval, but I don't know that this can be done. You can't even count, on some systems, on the session remaining in memory.
    If you really need to do this you may need to consider implementing sessions for yourself. I've done this for non-webapp based logins and it's not too hard.

  • Can anyone help with the java applet issue

    Hello everyone,
    This is my first thread in this forum,
    I need a little help with the form developer...
    I have oracle 9i db , 9i form developer
    I don't want to run the form i created as a java applet
    HOW IS THAT DONE i.e NOT IN THE INTERNET EXPLORER?????????
    ***IF ITS POSSIBLE

    Hello,
    I don't want to run the form i created as a java applet
    No chance, because the Web Forms client is an applet and cannot be anything else.
    Francois

  • Help with Times Table GUI applet

    Hello,
    I need help with an applet which inputs an integer from the user and displays the appropiate times table up to times 10 eg; user input 5 - display shows
    5 time 1 is 5
    5 times 2 is 10
    5 times 10 is 50.
    I have only managedt o get the display to show one statement eg 5 times 1 - I have tried using a for loop to show the whole table - but unlike a print statement each time the loop goes round it overwrites the data in the display box with the new data - any help would be much appreciated.
    Note: it is for a programming course year 1 exercise - so I can only use basic constructs or loops to achieve this. Thanks in advance! Heres what I have so far:
    import java.applet.* ;
    import java.awt.* ;
    import java.awt.event.* ;
    public class TimesTableApplet extends Applet implements ActionListener
         // Declare the GUI components globally
         Label titleLabel, whichTableLabel ;
         TextField whichTableBox, resultBox ;
         Button showTableButton, clearButton ;
         // Declare integer variables for holdind the number input by the user,
         // the times number, and the result number
         int whichTable, times=1, result ;
         // Declare variables to hold string versions of the three integer variables
         // above, for placing in the TextFields
         String whichTableString, timesString, resultString ;
         public void init ()
              // Create the Labels
              titleLabel = new Label ( "Times Table" ) ;
              whichTableLabel = new Label ( "Which Table?" ) ;
              // Create the TextFields
              whichTableBox = new TextField ( 5 ) ;
              resultBox = new TextField ( 30 ) ;
              // Create the Buttons
              showTableButton = new Button ( "Show Table" ) ;
              clearButton = new Button ( "Clear" ) ;
              // Add the components to the applet window
              add ( titleLabel ) ;
              add ( whichTableLabel ) ;
              add ( whichTableBox ) ;
              whichTableBox.addActionListener ( this ) ;
              add ( resultBox ) ;
              resultBox.setEditable ( false ) ;
              add ( showTableButton ) ;
              showTableButton.addActionListener ( this ) ;
              add ( clearButton ) ;
              clearButton.addActionListener ( this ) ;
         } // End of init method
         public void actionPerformed ( ActionEvent event )
              // Find out which button generated the event
              String arg = event.getActionCommand () ;
              // If the user clicks the clear button, clear the whichTableBox and
              // resultBox
              if ( arg.equals ( "Clear" ) )
                   whichTableBox.setText ( "" ) ;
                   resultBox.setText ( "" ) ;
              else
                   try
                        // Try extracting a string from the whichTableBox ( the users input )
                        // and converting it to an integer
                        whichTableString = whichTableBox.getText () ;
                        whichTable = Integer.parseInt ( whichTableString ) ;
                        // Clear status box
                        showStatus ( "" ) ;
                        // If the user clicks the showTableButton, display the appropiate
                        // times table up to times 10
                        if ( arg.equals ( "Show Table" ) ) ;
                             result = whichTable * times ;
                             timesString = Integer.toString ( times ) ;
                             resultString = Integer.toString ( result ) ;
                             resultBox.setText ( whichTableString + " times " + timesString + " is " + resultString ) ;
                   } // End of try block
                   catch ( NumberFormatException entry )
                        // Display error message and clear whichTableBox
                        showStatus ( "Error: Invalid Input - not an integer!" ) ;
                        whichTableBox.setText ( "" ) ;
                   } // End of catch block
              } // End of else statement
         } // End of actionPerformed method
    } // End of class

    use this code, please arrange your User interface correctly.
    * TimesTableApplet.java
    * Created on March 12, 2007, 12:08 PM
    * @author cc.woon
    import java.applet.* ;
    import java.awt.* ;
    import java.awt.event.* ;
    public class TimesTableApplet extends Applet implements ActionListener
    // Declare the GUI components globally
    Label titleLabel, whichTableLabel ;
    TextField whichTableBox ;
    TextArea resultBox;
    Button showTableButton, clearButton ;
    // Declare integer variables for holdind the number input by the user,
    // the times number, and the result number
    int whichTable, times=1, result ;
    // Declare variables to hold string versions of the three integer variables
    // above, for placing in the TextFields
    String whichTableString, timesString, resultString ;
    public void init ()
    // Create the Labels
    titleLabel = new Label ( "Times Table" ) ;
    whichTableLabel = new Label ( "Which Table?" ) ;
    // Create the TextFields
    whichTableBox = new TextField ( 5 ) ;
    resultBox = new TextArea() ;
    // Create the Buttons
    showTableButton = new Button ( "Show Table" ) ;
    clearButton = new Button ( "Clear" ) ;
    // Add the components to the applet window
    add ( titleLabel ) ;
    add ( whichTableLabel ) ;
    add ( whichTableBox ) ;
    whichTableBox.addActionListener ( this ) ;
    add ( resultBox ) ;
    resultBox.setEditable ( false ) ;
    add ( showTableButton ) ;
    showTableButton.addActionListener ( this ) ;
    add ( clearButton ) ;
    clearButton.addActionListener ( this ) ;
    } // End of init method
    public void actionPerformed ( ActionEvent event )
    // Find out which button generated the event
    String arg = event.getActionCommand () ;
    // If the user clicks the clear button, clear the whichTableBox and
    // resultBox
    if ( arg.equals ( "Clear" ) )
    whichTableBox.setText ( "" ) ;
    resultBox.setText ( "" ) ;
    else
    try
    // Try extracting a string from the whichTableBox ( the users input )
    // and converting it to an integer
    whichTableString = whichTableBox.getText () ;
    whichTable = Integer.parseInt ( whichTableString ) ;
    // Clear status box
    showStatus ( "" ) ;
    // If the user clicks the showTableButton, display the appropiate
    // times table up to times 10
    if ( arg.equals ( "Show Table" ) ) ;
    result = whichTable * times ;
    timesString = Integer.toString ( times ) ;
    String output = "";
    for(int i =1;i<=10;i++){
    output += whichTable +" times "+i + ": "+(i*whichTable)+"\n";
    resultString = Integer.toString ( result ) ;
    //resultBox.setText ( whichTableString + " times " + timesString + " is " + resultString ) ;
    resultBox.setText ( output) ;
    } // End of try block
    catch ( NumberFormatException entry )
    // Display error message and clear whichTableBox
    showStatus ( "Error: Invalid Input - not an integer!" ) ;
    whichTableBox.setText ( "" ) ;
    } // End of catch block
    } // End of else statement
    } // End of actionPerformed method
    } // End of class

Maybe you are looking for

  • W520 webcam no longer working after Windows 8.1 upgrade

    Hello, I upgraded my w520 from Win 7 to Win 8 last year with zero problems. Now I upgraded my W520 Win 8 to Win 8.1 via the store download. Except the webcam everything works fine. In e.g. the Skype desktop application, Google Hangouts or the camera

  • [SOLVED] Prev working xorg.conf won't work with new nvidia

    So I just upgraded to the latest nvidia driver.  Previously, my xfx 6600 and dell 2001fp could display 1600x1200 just fine, but now it's ratcheting X down to 1400x1050 (even though 1600x1200 is the only option I've specified in the xorg.conf). Any id

  • HT3906 How do i transfer contacts from iPhone4 to Ipod touch?

    I have my Iphone4 contacts saved on iCloud, but I traded in my iPhone4 waiting for a 5 to be available. I have a cheap phone temporarily with no contacts, but i have an ipod touch. how can i put my iphone4's contacts on the ipod touch?

  • Add-in Problem: Hyperion & Think-Cell issue

    Hi, As anyone experienced issues with Powerpoint and Hyperion Add-in? I have a user that is using Think-Cell (Powerpoint chart add-in). Think-Cell errors out on me every time exept when he removes the Hyperion Add-in from excel and close excel down c

  • Track Requests in Production System

    Hi Experts. I'm trying to find a way to get all requests that were transported to production system in a particular date. Do you know any table where I can find this information? I was looking in 'E070' tables group but it's seems like none of them r