Help in creating simple statefull EJB program

Hello , i m new to EJB and right now i m developing statefull ejb application. I have created stateless ejb application and it was working well but now facing some problem with maintaining state in statefull ejb application.
Here i m simply developing one counter application ... what i have done is as below ....
============================ CounterBean ================
package ejb;
import javax.annotation.PostConstruct;
import javax.ejb.Stateful;
@Stateful (mappedName="ejb/CounterBean")
public class CounterBean implements CounterBeanRemote {
private int _count;
@PostConstruct
public void initialize()
_count = 0;
public int increment() {
_count++;
return _count;
=================Remote interface for CounterBean==========================
package ejb;
import javax.ejb.Remote;
@Remote
public interface CounterBeanRemote {
public int increment();
=========================index.jsp===================jsp page to get result from ejb ========
<%@page contentType="text/html" pageEncoding="UTF-8" import="ejb.CounterBeanRemote,javax.naming.InitialContext"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%!
CounterBeanRemote _CBR = null;
%>
<%
InitialContext _IC = new InitialContext();
CBR = (CounterBeanRemote) IC.lookup("ejb/CounterBean");
out.println(_CBR.increment());
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
===============================================================
so, here every time i refresh my page counter should be increase as i m using statefull bean ...
but its not happening ....
every time i refresh page, all time result coming is only 1 ... its not incrementing .... can any one tell me what i m doing wrong ..... i m not able to maintain state ....
thnks .... please reply ....

The issue is not where to put the lookup code. The issue is that each call to InitialContext.lookup() produces a new Stateful session bean instance. It's the reference that is returned from lookup() that represents the interaction with a particular client. You'll need to store that reference somewhere across the multiple client interactions in order to maintain the statefulness you're looking for. Typically, that means storing it within the HttpSession.
--ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Help needed creating a linked list program

    I have been trying to create a linked list program that takes in a word and its definition and adds the word to a link list followed by the definition. i.e. java - a simple platform-independent object-oriented programming language.
    the thing is that of course words must be added and removed from the list. so i am going to use the compareTo method. Basically there a 2 problems
    1: some syntax problem which is causing my add and remove method not to be seen from the WordList class
    2: Do I HAVE to use the iterator class to go thru the list? I understand how the iterator works but i see no need for it.
    I just need to be pointed in the right direction im a little lost.................
    your help would be greatly appreciated i've been working on this over a week i dont like linked list..........
    Here are my 4 classes of code........
    * Dictionary.java
    * Created on November 4, 2007, 10:53 PM
    * A class Dictionary that implements the other classes.
    * @author Denis
    import javax.swing.JOptionPane;
    /* testWordList.java
    * Created on November 10, 2007, 11:50 AM
    * @author Denis
    public class Dictionary {
        /** Creates a new instance of testWordList */
        public Dictionary() {
            boolean done=false;
    String in="";
    while(done!=true)
    in = JOptionPane.showInputDialog("Type 1 to add to Dictionary, 2 to remove from Dictionary, 3 to Print Dictionary, and 4 to Quit");
    int num = Integer.parseInt(in);
    switch (num){
    case 1:
    String toAdd = JOptionPane.showInputDialog("Please Key in the Word a dash and the definition.");
    add(toAdd);
    break;
    case 2:
    String toDelete = JOptionPane.showInputDialog("What would you like to remove?");
    remove(toDelete);
    break;
    case 3:
    for(Word e: list)
    System.out.println(e);
    break;
    case 4:
    System.out.println("Transaction complete.");
    done = true;
    break;
    default:
    done = true;
    break;
       }//end switch
      }//end while
    }//end Dictionary
    }//end main
    import java.util.Iterator;
    /* WordList.java
    * Created on November 4, 2007, 10:40 PM
    *A class WordList that creates and maintains a linked list of words and their meanings in lexicographical order.
    * @author Denis*/
    public class WordList{
        WordNode list;
        //Iterator<WordList> i = list.iterator();
        /*public void main(String [] args)
        while(i.hasNext())
        WordNode w = i.next();
        String s = w.word.getWord();
        void WordList() {
          list = null;
        void add(Word b)
            WordNode temp = new WordNode(b);
            WordNode current,previous = null;
            boolean found = false;
            try{
            if(list == null)
                list=temp;
            else{
                current = list;
                while(current != null && !found)
                    if(temp.object.getWord().compareTo(current.object.getWord())<0)
                        found = true;
                    else{
                    previous=current;
                    current=current.next;
                temp.next=current;
                if(previous==null)
                    list=temp;
                else
                    previous.next=temp;
                }//end else
            }//end try
            catch (NullPointerException e)
                System.out.println("Catch at line 46");
        }//end add
    /*WordNode.java
    * Created on November 4, 2007, 10:40 PM
    *A class WordNode that contains a Word object of information and a link field that will contain the address of the next WordNode.
    * @author Denis
    public class WordNode {
        Word object;//Word object of information
        WordNode next;//link field that will contain the address of the next WordNode.
        WordNode object2;
        public WordNode (WordNode wrd)
             object2 = wrd;
             next = null;
        WordNode(Word x)
            object = x;
            next = null;
        WordNode list = null;
        //WordNode list = new WordNode("z");
        Word getWord()
            return object;
        WordNode getNode()
            return next;
    import javax.swing.JOptionPane;
    /* Word.java
    * Created on November 4, 2007, 10:39 PM
    * A class Word that holds the name of a word and its meaning.
    * @author Denis
    public class Word {
        private String word = " ";
        /** Creates a new instance of Word with the definition*/
        public Word(String w) {
            word = w;
        String getWord(){
            return word;
    }

    zoemayne wrote:
    java:26: cannot find symbol
    symbol  : method add(java.lang.String)
    location: class Dictionary
    add(toAdd);this is in the dictionary class
    generic messageThat's because there is no add(...) method in your Dictionary class: the add(...) method is in your WordList class.
    To answer your next question "+how do I add things to my list then?+": Well, you need to create an instance of your WordList class and call the add(...) method on that instance.
    Here's an example of instantiating an object and invoking a method on that instance:
    Integer i = new Integer(6); // create an instance of Integer
    System.out.println(i.toString()); // call it's toString() method and display it on the "stdout"

  • Need help to run  The First EJB program

    hello i m new to the ejb
    i tried to run the very simple exaple i was able to compile the following code and deploy them to the j2ee server but i wavs un able to run the cilent program in the same machine
    here are the codes
    // this is remote intterface class
    public interface remote extends javax.ejb.EJBObject{
    public String show() throws java.rmi.RemoteException;
    //home interface
    import javax.ejb.*;
    import java.rmi.*;
    public interface homeinter extends EJBHome{
    remote create()throws CreateException,RemoteException;
    //bean
    import javax.ejb.SessionBean;
    import javax.ejb.EJBException;
    import java.rmi.RemoteException;
    import javax.ejb.SessionContext;
    public class bean implements SessionBean {
    SessionContext sct;
    public String show() throws RemoteException {
    return " this is from bean";
    public void ejbActivate(){}
    public void ejbPassivate(){}
    public void ejbCreate(){}
    public void ejbRemove(){}
    public void setSessionContext(SessionContext set){
    this.sct=set;
    // client
    import javax.ejb.*;
    import javax.rmi.*;
    import javax.naming.*;
    import java.rmi.*;
    public class client {
    public static void main(String[] args) {
    try{
    InitialContext ic= new InitialContext();
    Object obj= ic.lookup("MySecond");
    homeinter h=(homeinter)PortableRemoteObject.narrow(obj,homeinter.class);
    remote r=h.create();
    System.out.println("the return value is" + r.show());
    }catch(Exception e){
    e.printStackTrace();
    in the DOS prompt i tried to run the programme like
    set CPATH=.;c:\j2ee\lib\j2ee.jar;secondClient.jar
    java -Dorg.omg.CORBA.ORBInitialHost=lacalhost -classpath %CPATH% client
    then i had the following error mesage
    C:\ejb>set CPATH=.;c:\j2ee\lib\j2ee.jar;secondClient.jar
    C:\ejb>java -Dorg.omg.CORBA.ORBInitialHost=Localhost -classpath .;c:\j2ee\lib\
    j2ee.jar;secondClient.jar client
    Exception in thread "main" java.lang.NoSuchMethodError: loadClass0
    at com.sun.corba.ee.internal.util.JDKClassLoader.specialLoadClass(Native
    Method)
    at com.sun.corba.ee.internal.util.JDKClassLoader.loadClass(JDKClassLoade
    r.java:58)
    at com.sun.corba.ee.internal.util.JDKBridge.loadClassM(JDKBridge.java:18
    0)
    at com.sun.corba.ee.internal.util.JDKBridge.loadClass(JDKBridge.java:83)
    at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.loadClass(Util.java:37
    8)
    at javax.rmi.CORBA.Util.loadClass(Unknown Source)
    at javax.rmi.PortableRemoteObject.createDelegateIfSpecified(Unknown Sour
    ce)
    at javax.rmi.PortableRemoteObject.<clinit>(Unknown Source)
    at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav
    a:57)
    at com.sun.enterprise.naming.SerialContext.<init>(SerialContext.java:79)
    at com.sun.enterprise.naming.SerialInitContextFactory.getInitialContext(
    SerialInitContextFactory.java:54)
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at client.main(client.java:10)
    pls give me a solution
    thank you

    1. which app server u r using ? R u using RI ?
    2. what is this secondclient.jar ?
    3. Have u added server specific jar containing implementation of IntialConrtextFactory in the classpath of client?
    4. If using RI, then I suppose u will have to set "Support Client Choice" (Possibly) to true, then generate client.jar.
    5. Which IDE u r using (If any) ?
    6. Are u sure that ur jar file (containng EJBs) deployed successfully ?
    7. Almost every server provides GUI console sort of , u can check whether it was deployed successfuly ?
    Pls update
    GiveMeJ
    Sanjeev

  • Help to create simple Applescript

    Hi, hopefully somebody will be able to help me with a simple Applescript.
    I want to be able to drag a pdf file onto a desktop icon, enter a new filename into a dialogue box and for the file to be copied to a specific folder. It will only be pdf files, and I want it to automatically append the .pdf extension.
    Could sombody possibly point me in the right direction? Thanks in advance.

    Oops, forgot one more check. If a file exists with the same name as the original file, then it will error when you duplicate it. One way to solve that is to duplicate in place. Then "copy" is added to the name. You then move the file to the destination folder and probably there is no file with "copy" in its name.
    property folder_location : (path to desktop)
    property folder_name : "Files"
    on open these_items
    -- added check for main folder
    tell application "Finder"
    try
    set main_folder to (folder folder_name of folder_location) as alias
    on error
    set main_folder to (make new folder at folder_location with properties ¬
    {name:folder_name})
    end try
    end tell
    repeat with this_item in these_items
    set n to name of (info for this_item)
    if n ends with ".pdf" then
    set temp_prompt to "Enter a name for duplicate of " & n & ":"
    repeat
    display dialog temp_prompt default answer "name"
    set new_name to (text returned of result) & ".pdf"
    tell application "Finder"
    if not (exists file new_name of main_folder) then
    set the_duplicate to (duplicate this_item) as alias
    move the_duplicate to main_folder
    set name of the_duplicate to new_name
    exit repeat
    else -- inform user to enter a different name
    set temp_prompt to "Enter a different name. The name " & new_name & " is used."
    end if
    end tell
    end repeat
    end if
    end repeat
    end open
    Otherwise, What I usually do is create a empty temp folder for doing renaming, but then it gets more complicated. For now, just don't use "copy" in names.
    gl,

  • Create  simple session EJB and a client web application using eclipse IDE

    Hi,
    I am having Problem when I Tried call the EJB from the JSP. I am Using ECLIPSE3.2 as IDE and Weblogic 8.1 as SERVER.
    I am Getting the Following Exception in the Console when Running The JSP.
    weblogic.servlet.jsp.CompilationException: Compilation of C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java failed.
    at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:446)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:220)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:172)
    at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:504)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:349)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:431)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Caused by: java.io.IOException: Compiler failed executable.exec
    at weblogic.utils.compiler.CompilerInvoker.compileMaybeExit(CompilerInvoker.java:470)
    at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:329)
    at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:337)
    at weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:322)
    at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:419)
    ... 13 more
    And In JSP Page I am getting the Following Error.
    Compilation of 'C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java' failed:
    C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:17: package com.qwert does not exist
    probably occurred due to an error in /test.jsp line 2:
    pageEncoding="ISO-8859-1"%>
    C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:127: cannot resolve symbol
    probably occurred due to an error in /test.jsp line 12:
    Qwert qwert = null;
    C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:129: cannot resolve symbol
    probably occurred due to an error in /test.jsp line 14:
    QwertHome home = QwertUtil.getHome();
    C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:129: cannot resolve symbol
    probably occurred due to an error in /test.jsp line 14:
    QwertHome home = QwertUtil.getHome();
    Full compiler error(s):
    {noformat}C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:17: package com.qwert does not exist
    import com.qwert.*; //[ /test.jsp; Line: 2]
    ^
    C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:127: cannot resolve symbol
    symbol : class Qwert
    location: class jsp_servlet.__test
    Qwert qwert = null; //[ /test.jsp; Line: 12]
    ^
    C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:129: cannot resolve symbol
    symbol : class QwertHome
    location: class jsp_servlet.__test
    QwertHome home = QwertUtil.getHome(); //[ /test.jsp; Line: 14]
    ^
    C:\bea\WEBLOG~1\samples\domains\workshop\.\cgServer\.wlnotdelete\extract\cgServer__appsdir_qweb_war_qweb\jsp_servlet\__test.java:129: cannot resolve symbol
    symbol : variable QwertUtil
    location: class jsp_servlet.__test
    QwertHome home = QwertUtil.getHome(); //[ /test.jsp; Line: 14]
    ^
    Please Let me Know Solution for This. Thanks in Advance.
    {noformat}

    Hai.
    I think u didnt start the server.

  • How to create reports for java programs?

    Hi,
    I have planned to do a project using java,that will help to create reports for java programs. To create reports for java programs i used two options.
    1)Crystal reports
    2)Write the code to produce reports for each java programs
    The second one little cumbersome.SO i planned to develop a software that is compatible for creating java reports.
    I would like to know how i will do the project?Can you help me to made it a successful project.Hope you can help me.
    Expecting your reply
    PreethiRenjith

    Uggg... Crystal reports...
    I would personally write a generic report generator, It would probably be easier than fighting w/
    crystal reports (CR is popular, but painful :) )
    Anyhow, I've written report generators for many different applications. It is one of the simplest projects you
    can take on, and the results make you feel special --
    If your need nicely formated, portable, printable reports, you could have your report generator make PDF files (the format is open, and VERY simple, plus people like pdf files) you can get the pdf spec from adobe or from wotsit.org (the famous wotsit file format archive).
    enjoy!

  • Creation of Simple JSP DynPage program

    Hi Experts,
    Could you please send me some link to create simple JSP DynPage program.
    Regards,
    RK

    Hi,
      Check these..
    http://help.sap.com/saphelp_nw2004s/helpdata/en/f5/cfa441cd47a209e10000000a155106/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/d0/d4a441cd47a209e10000000a155106/content.htm
    https://www.sdn.sap.com/irj/sdn/thread?messageID=223649#223649
    Regards,
    Harini S

  • Help plss Should a cursor be created in database or program unit in forms l

    Where can i create a cursor should it be in database i.e isql plus using internet explorer or should i create the cursor in forms
    forms can i create the cursor so that i can use the cursor in the post item trigger of the userid item of login page
    Can i create the cursor in a package specification and how can i call that cursor into a post_text item trigger
    details below
    Iam working on a Online exam for students Dummy project using forms
    The student 1st comes to a WELCOME page i.e form which asks him if he is a new student or registered stud
    If he clicks registered pushbutton it takes him to a LOGIN page where there are two items userid and password.I am using a Validate_item OR Post_item trigger to fire after the student enters his userid.
    I need to compare the entered userid with the userid stored in the database STUDENTS table which i created which consists of the registered students details.
    Our project Guide suggested that we create a cursor and fetch each userid everytime into the cursor and compare the entered userid with the cursor.

    hi Sqlstar,
    Regarding to your all questions , i prefered that you search for a simple document or book in order to understand much more more about creating cursors.
    however since this forum made to help people and to make a integerated community i would be glad to offer my help and going with you step bt step with your answers.
    as for beginning
    1) when you create the user_exists function in database , if you want to call it in the form level you would wirte a code like this
    ----WHEN-VALIDATE-ITEM------------user_id item---------
    IF scheme_name.procedure_name(:block1.userid)!='TURE' then
       message('User Name is not correct');
       raise form_trigger_failure;
    end if;
    2) it's not a waste of recourse to make 2 validation of both userid and password
    and as same you create a procedure for useris you should create a procedure for password where the user id is the outcomming of userid item in the form.
    3)you have all choices to create the 2 procedures on database side or in the program unit at design time for the form it's up to you and as a small hint for you ,
    when you create them in the program unit and want to call the procedures in the WHEN-VALIDATE-ITEM  trigger you should denote the procedure name with the name of package first as following
    -------[Package Spec Code]-------
    PACKAGE user_validation IS
    function user_exists (p_user_id number) return boolean;
    end ;
    --------------[Package Body Code]------
    PACKAGE BODY user_validation IS
    function user_exists (p_user_id number) return boolean
    is
    user_number number;
    cursor c_user_id is
    select user_id from <user_table>
    where user_id=p_user_id;
    begin
    open c_user_id ;
    loop
    fetch user_id  into user_number ;
    return (true);
    exit when c_user_id%NOTFOUND;
    end loop;
    execption  when others then
    return(false);
    end user_exists;
    end;
    -----Calling at Validation level-----------
    IF (user_validation.user_exists(:block1.userid))!=TURE then
       message('User Name is not correct');
       raise form_trigger_failure;
    end if;
    i hope this could be helpful engouh to start your application
    Good Luck .
    Regards
    Omar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How do I create a simple "prize draw" program?

    Hey, I'd like to create a simple "prize draw" program
    that randomly selects a name (or number) from a list of names, I'd like it to be my own custom version. For a programmer this is probably the easiest thing but I'm new to programming (beginner), don't eve know if I'm in the right subcategory (flash). Is there a tutorial or something somewhere that you guys think could help me out, please?

    Create the list as an array and use the Math methods to randomly pick one of the values from the array.
    var prizeArray = new Array("name1","name2");
    var drawnPrize = prizeArray[Math.floor(Math.random()*prizeArray.length)];
    trace(drawnPrize);
    If you don't know if you should be using Flash, then you probably don't want to be looking for help until you figure out what you intend to do for your custom design.

  • Help with a simple program.

    I need some help writing a simple program. Can anybody help??
    thanks to all.
    2. HTML Java Source Code Reserved Word Highlighter
    Write a program that inputs a Java source code file and outputs a copy of that file with Java keywords surrounded with HTML tags for bold type. For example this input:
    public class JavaSource
    public static void main ( String[] args )
    if ( args.length == 3 )
    new BigObject();
    else
    System.out.println("Too few arguments.");
    will be transformed into:
    <B>public</B> <B>class</B> JavaSource
    <B>public</B> <B>static</B> <B>void</B> main ( String[] args )
    <B>if</B> ( args.length == 3 )
    <B>new</B> BigObject();
    <B>else</B>
    System.out.println("Too few arguments.");
    In a browser the code will look like this:
    public class JavaSource
    public static void main ( String[] args )
    if ( args.length == 3 )
    new BigObject();
    else
    System.out.println("Too few arguments.");

    Here is something that may get you started...
    import java.io.*; 
    import java.util.*; 
    public class HtmlJava{
         public static void main(String arg[]){
              if(arg.length!=1){
                   System.out.println("Usage java HtmlJava sourceFile");       
              else
                   new HtmlJava(arg[0]);
         HtmlJava(String source){
              try{
                   BufferedReader sourceReader=new BufferedReader(new InputStreamReader(new FileInputStream(source)));
                   BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(source+"Html.txt")));  
                   Vector keywords=new Vector();
                   addKeywords(keywords);
                   String line;
                   StringTokenizer tokenizer=null;
                   String word;
                   while((line=sourceReader.readLine () )!=null){
                        tokenizer=new StringTokenizer(line);
                        while(tokenizer.hasMoreTokens()){
                             word=tokenizer.nextToken();
                             if(keywords.contains(word)){
                                  writer.write(""+word+" ");
                             else{
                                  writer.write(word+" ");
                        writer.write("\r\n");
                   writer.close();
                   sourceReader.close(); 
                   System.out.println("Output File written to "+source+"Html.txt"); 
              catch(Exception ex){
                   ex.printStackTrace();      
         private void addKeywords(Vector keywords){
              keywords.addElement ( "abstract");
              keywords.addElement( "boolean");
              keywords.addElement( "break");
              keywords.addElement( "byte");
              keywords.addElement( "byvalue");
              keywords.addElement( "case");
              keywords.addElement( "cast");
              keywords.addElement( "catch");
              keywords.addElement( "char");
              keywords.addElement( "class");
              keywords.addElement( "const");
              keywords.addElement( "continue");
              keywords.addElement( "default");
              keywords.addElement( "do");
              keywords.addElement( "double");
              keywords.addElement( "else");
              keywords.addElement( "extends");
              keywords.addElement( "false");
              keywords.addElement( "final");
              keywords.addElement( "finally");
              keywords.addElement( "float");
              keywords.addElement( "for");
              keywords.addElement( "future");
              keywords.addElement( "generic");
              keywords.addElement( "goto");
              keywords.addElement( "if");
              keywords.addElement( "implements");
              keywords.addElement( "import");
              keywords.addElement( "inner");
              keywords.addElement( "instanceof");
              keywords.addElement( "int");
              keywords.addElement( "interface");
              keywords.addElement( "long");
              keywords.addElement( "native");
              keywords.addElement( "new");
              keywords.addElement( "null");
              keywords.addElement( "operator");
              keywords.addElement( "outer");
              keywords.addElement( "package");
              keywords.addElement( "private");
              keywords.addElement( "protected");
              keywords.addElement( "public");
              keywords.addElement( "rest");
              keywords.addElement( "return");
              keywords.addElement( "short");
              keywords.addElement( "static");
              keywords.addElement( "super");
              keywords.addElement( "switch");
              keywords.addElement( "synchronized");
              keywords.addElement( "this");
              keywords.addElement( "throw");
              keywords.addElement( "throws");
              keywords.addElement( "transient");
              keywords.addElement( "true");
              keywords.addElement( "try");
              keywords.addElement( "var");
              keywords.addElement( "void");
              keywords.addElement( "volatile");
              keywords.addElement( "while");
    }Hope it helped

  • Problems with a simple stop watch program

    I would appreciate help sorting out a problem with a simple stop watch program. The problem is that it throws up inappropriate values. For example, the first time I ran it today it showed the best time at 19 seconds before the actual time had reached 2 seconds. I restarted the program and it ran correctly until about the thirtieth time I started it again when it was going okay until the display suddenly changed to something like '-50:31:30:50-'. I don't have screenshot because I had twenty thirteen year olds suddenly yelling at me that it was wrong. I clicked 'Stop' and then 'Start' again and it ran correctly.
    I have posted the whole code (minus the GUI section) because I want you to see that the program is very, very simple. I can't see where it could go wrong. I would appreciate any hints.
    public class StopWatch extends javax.swing.JFrame implements Runnable {
        int startTime, stopTime, totalTime, bestTime;
        private volatile Thread myThread = null;
        /** Creates new form StopWatch */
        public StopWatch() {
         startTime = 0;
         stopTime = 0;
         totalTime = 0;
         bestTime = 0;
         initComponents();
        public void run() {
         Thread thisThread = Thread.currentThread();
         while(myThread == thisThread) {
             try {
              Thread.sleep(100);
              getEnd();
             } catch (InterruptedException e) {}
        public void start() {
         if(myThread == null) {
             myThread = new Thread(this);
             myThread.start();
        public void getStart() {
         Calendar now = Calendar.getInstance();
         startTime = (now.get(Calendar.MINUTE) * 60) + now.get(Calendar.SECOND);
        public void getEnd() {
         Calendar now1 = Calendar.getInstance();
         stopTime = (now1.get(Calendar.MINUTE) * 60) + now1.get(Calendar.SECOND);
         totalTime = stopTime - startTime;
         setLabel();
         if(bestTime < totalTime) bestTime = totalTime;
        public void setLabel() {
         if((totalTime % 60) < 10) {
             jLabel1.setText(""+totalTime/60+ ":0"+(totalTime % 60));
         } else {
             jLabel1.setText(""+totalTime/60 + ":"+(totalTime % 60));
         if((bestTime % 60) < 10) {
             jLabel3.setText(""+bestTime/60+ ":0"+(bestTime % 60));
         } else {
             jLabel3.setText(""+bestTime/60 + ":"+(bestTime % 60));
        private void ButtonClicked(java.awt.event.ActionEvent evt) {                              
         JButton temp = (JButton) evt.getSource();
         if(temp.equals(jButton1)) {
             start();
             getStart();
         if(temp.equals(jButton2)) {
             getEnd();
             myThread = null;
         * @param args the command line arguments
        public static void main(String args[]) {
         java.awt.EventQueue.invokeLater(new Runnable() {
             public void run() {
              new StopWatch().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JPanel jPanel1;
        // End of variables declaration                  
    }

    Although I appreciate this information, it still doesn't actually solve the problem. I can't see an error in the logic (or the code). The fact that the formatting works most of the time suggests that the problem does not lie there. As well, I use the same basic code for other time related displays e.g. countdown timers where the user sets a maximum time and the computer stops when zero is reached. I haven't had an error is these programs.
    For me, it is such a simple program and the room for errors seem small. I am guessing that I have misunderstood something about dates, but I obviously don't know.
    Again, thank you for taking the time to look at the problem and post a reply.

  • Need Help to create new screen for RF Sapconsole

    Hi Guru's
    I'm new on RF (but some years in ABAP) since last week.
    I need help to create new screens for RF (SAPLLMOB).
    Can someone explain me the procedure to create screen (with ABAP code after) or perhaps someone have an exemple (simple or not) ?
    I have to develop 2 new screens with really few time.
    And, another subsidiary question :
    how SAP can transfert information between the flash gun and the screen i have developped.
    Is there some code to add to enable this functionality or it is include in SAPLLMOB on standard fields ????
    It's a new strange world for me today...
    Many thanks to everyone who can explain me
    Alain

    hi,
    I am facing this problem as well. Is there any reference to create the new screen?
    Hope someone can help! Thanks!
    Regards,
    Darren

  • Need help to create report with jpeg/gif image

    Hello,
    I need help with creating a form with a special jpeg/gif seal. I never done this Java. Until now, I created all forms with ansi C++ with HP escape characters to draw lines, boxs, and text. This form will contain boxes which is populated with database information read from a text file.
    Since this form contains a special seal on the upper right, I don't think it can be done with old fashion ansi C++. How can I create a form with Java and create it as a simple exe to just print the form to a specified printer.
    Thanks,
    John

    Hi,
    I am creating a form with boxes (lines and text). What is special about this form is that it has an image jpeg or gif at the top right corner. Is is a state department seal. Up to this form, I had used ansi C++ and print out escape HP character to print out the lines, boxes, and text. I have no idea how to print out the image. I am new to JAVA and only 1 class in it. Is there sample code out there to create this type of form with the image? I need a starting point.
    Thanks,
    John

  • How can I create a new EJB project ?

    Hi,
    I downloaded the trial version and I don't know how to create an EJB project ?
    When I create a new project, I've only the web template to choose.
    Where can I find informations about that ?
    Thanks.
    jack

    Hi Jack,
    This version of the Creator allows you to build applications which access existing EJB's, but doesn't create new EJB's from scratch. We are looking into that for future releases.
    If you want to access an existing EJB, please see the tutorials:
    http://devservices.sun.com/premium/jscreator/standard/learning/tutorials/sessionEJBcomps.pdf
    I believe the Sun Java Studio Standard product can help you create EJB's today, if that's what you need:
    http://developers.sun.com/prodtech/javatools/jsstandard/index.html
    hth,
    Val

  • Please help me creating a new listener with different port#.

    I have two instances in a server. both have different homes. I want to create a seperate listener for the second one i created.
    But that is not happening.
    here i tried to give name from LISTENER TO LISTENER1 & Port# from 1521 to 1524.
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = /apps2/oracle)
    (PROGRAM = extproc)
    LISTENER1 =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aixth53)(PORT = 1524))
    When I check lsnrctl status with LISTENER1 , it still shows the other instance home with port#: 1521
    Please help me creating a new listener with different port#.
    Thanks,

    marist89 wrote:
    sb92075 wrote:
    marist89 wrote:
    sybrand_b wrote:
    The listener is a broker only and doesn't play any role in normal communications.
    It just forks a process or a thread, and that's it.And the listener is a single point of failure. Listener goes down, you can't connect to the db. That's why you need two listeners.If listener one goes down, then listener two goes down for exact same reason since it is a single executable file.I'm not playing tit-for-tat with you. Fact is, there are situations where people who are not you might want to use more than one listener.Some folks might want to jab a sharp pencil into their eye, too.
    Just because you can do something, it does not necessarily mean it should be done.

Maybe you are looking for

  • I am having a problem with my Blackberry Curve's "Convenien​ce Keys."

    My Convenience Keys (voice command and camera) randomly stopped working! When I try to use the voice command (even after troubleshooting), it does not respond at all and the camera asks me to close all other applications in order for it to operate! W

  • Change over from reorder planning to forecast -reg

    Hi, Currently we are using for some parts manual  reorder point planning  wth MRP type V1 and strategy 40 We require to change to forecast based planning where in we can change MRP type to VV and  what strategy we have to put any specific for forecas

  • Which rechargeable batteries should I buy for the ...

    Just wondering which batteries to buy for the phone as the person who last bought them has chucked the old ones out and now we don't know which ones to get? The range seems to be from 1300Mah downwards...  Help!

  • Positioning of text

    I'd like to create a block of text on a blank page that is centered both horizontally and vertically no matter what the size of someone's screen or browser is. Is it possible to do this in Contribute?

  • How do I print a copy fo my icloud calendar

    How do I print my icloud calendar?