javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because you only have ONE tempPerson object. You have the same instance of it:

tempPerson.setPerson(tempName, tempAddress, tempBirthDate);

System.out.println(tempPerson.getLastName()); // <-- OK here

student.add(new Student(tempPerson, tempCompDate, gpa, credits));

System.out.println(student.get(counter).getPerson().getLastName());

The last system.out at the above code prints the name correctly because it is the last one read from the loop. Then when you loop again you replace the name in the tempPerson object, and you put the latest in the list. Then you print what you read and you see correct results.
But
You put in the Student object the tempPerson. So when you do this: tempPerson.setPerson(tempName, tempAddress, tempBirthDate); you change the value of tempPerson.
Since in java all the objects are passed by reference ALL the student objects you created have the SAME tempPerson instance.
So when you change the tempPerson, it changes that tempPerson in all the Students that are in the ArrayList.

Inside the loop you create a new Student each time before you put it in the list: student.add(new Student(tempPerson, tempCompDate, gpa, credits)); Do the same for the rest:

tempName = new ....();
tempAddress = new ....();
tempBirthDate = new ....();
tempPerson = new ....();
tempCompDate = new ...();

tempName.setName(firstName, middleInitial, lastName, suffix);
tempAddress.setAddress(addLine1, addLine2, city, state, zip);
tempBirthDate.setDate(BirthDayDateInt, BirthDayMontInt, BirthDayYearInt);
tempPerson.setPerson(tempName, tempAddress, tempBirthDate);
tempCompDate.setDate(CompletionDayInt, CompletionMonthInt, CompletionYearInt);
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

im just getting an endless output of the input number

Because you are increasing the index in the loop. If you want this:
11,10,9,8,7,6 then the numbers will be decreasing so you need to decrease the index at the loop.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You should have made this a code snippet. Nevertheless it is very simple example, very useful only for beginners.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

How many lines does the file has because you are not reading it correctly.
If the line you read is like this:
> Field_Name Menu Item
Then the array will have the elements of ONE row and you need to put all of them in ONE row:

String arr[] = line.split("\t");

dm.insertRow(i,new Object[]{i+1,arr[0], arr[1], arr[2]});

Try this first.

Then instead of an if (scanner.next()) you must have a while in order to read all the lines.

Also, why the DefaultTableModel has to be final?

And this:

String col0 = "Field#";
String col1 = "Field Name";
final String col2 = "Menu";
final String col3 = "Item";
dm.addColumn(col0);
dm.addColumn(col1);
dm.addColumn(col2);
dm.addColumn(col3);

has to be outside the while. You add the columns only once. then in while loop you insert as many rows as needed

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try a for loop, start would be one of the numbers and the end the other. Check to see which one is greater in case you need to display them in descending order, by reducing the index instead of increasing.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It will work, but don't forget that each element of the iterator will have one of these:
java.util.Map.Entry

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't know. Have you checked the API for Treemap?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try run it without the .class extension:
> java Hi

Then post the error that you will get :)

darkagn commented: snap +3
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

i am a biginner in java programming,i would like to know how we can identify and correct types of errors in java program?

Next time start a new Thread. Someone else has started this and expects to find answers to his problem, not yours.

> Also the compile errors tell you at which line the error is and they have a brief description of the error.
> The exception tell you the line were the exception happened. Look for the first line of the message, that indicates your class.
> ALWAYS look the API of the classes you are using:
http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html
or search the internet for the API of the class you are using.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You need to use java.util.Date, not java.sql.Date.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When you get that error it means that something is null. At that line it means that 'fc' is null. Did you initialize it? Because I didn't see it in your code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Notwithstanding the validity of the above, you cannot simply create the array at the beginning as the program implies you do not know the number of records until the last one is indicated by entering Stop. Your own approach of creating a new variable each time to add to the array is correct.

The problem occurs in the values of index used. The input index 'i' is incremented after the record is saved and the next item requested or the end indicated. When stop is entered the loop exits without creating any new variable or extending the array, so the value of i is 1 beyond the last array element. In the printout you add 1 to i to ensure the for loop index reaches the last value of i which has no entry in the data. This is where the error will occur.

You are right, I didn't see that part of the code: pippo[i] = new Partysupply(); in the loop.

Good job taking some time to look it up

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Yes, but you didn't say what the error is. The code seems fine. What is your problem?

Also you should post a few lines of the file you are reading.
Also check the API for the class: Scanner:
http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html
You will find it at the link: java.util at the left column.

Its method: nextLine returns the entire line, so I assume that the file you are reading is like:

lastName
firstName
middleInitial
..
..


..
lastName
firstName
middleInitial

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

for multiple try-catch statement, you have to close it with one final statement which is "finally{}"

The above is not quite correct. You make it sound like it is necessary to put a finally block which is not. In your code you specify that it is not obligatory, but at your description above you accidentally give the impression that a finally block is always needed.


But this is wrong:

Import java.lang.String;

The above is absolutely not needed to be added

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your problem is reading the file. What is the format of the file. Can you post some of its data.

Also I would suggest to create an object with properties the data you are reading:

class YourClass {
  private String employeeName=null;
  private int employeeNum=0;
....
// declare constructor and get/set methods
}

Then read the entire file. As you read it create instances of your class and put them into a Vector.
Check the API for the Vector. Then whenever the "Next" button is clicked get from the Vector the next element.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
Partysupply[] pippo = new Partysupply [20];

pippo[0] = new Partysupply();

You need to initialize all the elements of the array. With your code, you initialize the pippo[0] but the pippo[1], pippo[2], pippo[3] are null.

Don't forget that when you do this: pippo = new Partysupply [20]; You initialize the array, not the elements of the array.

And I believe that these calls are not needed:

pippo[0] = new Partysupply(); //class used to add to the array

[B]        pippo[0].getItem();
        pippo[0].getQuant();
        pippo[0].getPrice();
        pippo[0].getItemno();
        pippo[0].getLoanAmount();[/B]
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Download a jdk from java site. Read tutorials on how to compile with the javac command, or use an IDE like eclipse

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I already told you. If you have a table in jsp:

<table>
 <tr>
  <td>
  </td>
 </tr>
</table>

And you want different colors in each cell or row or column then you use css.

Unless the code I posted is not what you meant.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

And are we suppose to do? From what I read you didn't ask any questions in your post.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
while (repeat =true)

Do you really want an infinite loop ? if yes you can use while(true) , not a good coding practice I would say.

I believe it would be better to let him start a new thread, before responding to any questions.

Thanks

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

All right brother. I got wad r u trying to say. One more problem bro. How do you choose an element from the JList( single click ) and when i click a button called Loan, it will appear a jOptionPane tellin me if i want to borow the book.

I would suggest, before asking such questions, first to check the java API:
java API
javax.swing
JList
getSelectedValue()

When you click the button, inside the actionPerformed, call that method (getSelectedValue) I assume that you have added "Patron" objects inside the list. If that method returns something other than null, means that you have selected something at the list. Then you can cast it to "Patron" and you are ready to do whatever you want.
Also if you need to cast it to some other of the "child" classes then I have showed you a way with the "instanceOf" keyword:

Patron patron = (Patron)list.getSelectedValue();

//either use the methods of the super class, or do some more casting:
if (patron instanceOf UnderGraduate) {
     UnderGraduate unGrad = (UnderGraduate)patron;
} else if (...) { ... }

I don't quite remember the "instanceOf " syntax so you might want to double check it by searching for it at the internet.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You don't run the programs, you call the methods. If the other programs are inside a main, then take that code and declare it as a method and call the method. For arguments, You might want to add some JTextFields. Check the API for JTextFields.

An example on how to do that thing with the main:

public static void main(String [] args) {
     [B]int a = 5;
     int b = 4;[/B]
     [B]int sum = a + b;[/B]
     System.out.println("Sum = "+sum);
}

Should be:

public class SomeUtilities {
    public static int getSum([B]int a, int b[/B]) {
        [B]int sum = a + b;[/B]
        return [B]sum[/B];
   }
}

At your "swing" code, you call the methods from the other classes. If you don't know how to do that I suggest you study some more on how to call and declare methods.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Here:

For code tags click the button: (code) when you write your post

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Let’s say they get on the bus on ‘stop 3’ and go to ‘stop 9’, how would I code this?

From stop 3 to stop 9 there are:
3,4,5,6,7,8,9 stops. The first doesn't count because the passenger has just entered the bus so you can not charge him for the stop entered. So he traveled: 4,5,6,7,8,9 stops = 6 stops in total:
'stop 9' - 'stop 3' = '6 stops to charge'

Then use if statements:

//the fare for up to 3 stops is charged £4
int [B]charge[/B] = 4; // that would be the initial value

//after that each stop is calculated as £2
if stops more than 3 then add to [B]charge[/B] 2 for each stop beyond the 3rd

To avoid negative values you can use the absolute value. If the number of stops is negative multiply it by -1 to turn it into positive

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You don't need the newPatron object. In the if statements you will only have one instance. You will not have an instance of the super class. Only of child classes. The way you have it in the if statements, you put some data in:
newPatron: newPatron.setName(txtPatronName.getText()); and some in newGraduatePatron: newGraduatePatron.setAdvisor(txtGradAdvisorName.getText()); Then which one will you put in the list. Remember, the chilcd class have access to the super methods:

public class Father {
   public String name;
   public String getName() {
      return name;
   }
    public void setName(String name) {
        this.name = name;
    }
}

public class Child1 extends Father {
   public int age;
   public int getAge() {
      return age;
   }
    public void setAge(int age) {
        this.age = age;
    }
}

// SO:
{
    Child1 ch1 = new Child1();
     ch1.[B]setName[/B]("Name");
     ch1.[B]setAge[/B](11);
}

In your code you can have this:

private void GetPatronDetails()
	{
		if(GradPatron.isSelected())
		{
			newGraduatePatron.setName(txtPatronName.getText());
			newGraduatePatron.setAddress(txtPatronAdd.getText());
			newGraduatePatron.setPhoneNo(txtPatronTphone.getText());
			newGraduatePatron.setPatronID(txtPatronNum.getText());
			newGraduatePatron.setAdvisor(txtGradAdvisorName.getText());
			newGraduatePatron.setGradProgram(txtGraduateProg.getText());

[B]// add to list the newGraduatePatron[/B]
		}
		else
			if(UnderGradPatron.isSelected())
			{
......
[B]// add to list the newUnderGradPatron[/B]
			}
			else
				if(FacPatron.isSelected())
			    {
		
.....
[B]// add to list the newFacultyPatron[/B]
			    }	
	}

Or you can have the above method return the patron:

private Patron GetPatronDetails()
	{
		if(GradPatron.isSelected())
		{
			// get the data from the fields
    return newGraduatePatron;
		}
		else
			if(UnderGradPatron.isSelected())
			{
							// get the data from the fields
return newUnderGradPatron;
			}
			else
				if(FacPatron.isSelected())
			    {
						// get the data from the fields
return newFacultyPatron;
			    }	
	}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Isn't this suppose to throw an ArrayIndexOutOfBounds Exception?:

names[names.length] = ...

names's length is 1 java.lang.ArrayIndexOutOfBoundsException: [B]1[/B]

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because you are saving the object as binary data not as text. You are serializing. You cannot open the file and view it. If you want to read it then use the opposite way.

FileInputStream
ObjectInputStream

If you want to save it as text then use BufferedWriter, but it needs much more work. With your way, you did it in 3-4 lines.

I hope that your class implements the java.io.Serializable interface.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What is the editor? The code that generates the date seems fine.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You are calling the "equals" method and in your class you have created a "eqls" method.

Your class need to override the "equals" method:
http://java.sun.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object)

Since you haven't overridden the equals method in your class, in the main, the equals of the super class is called (Object class) that checks if 2 objects are the same instance, not if they have the same value

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Inside the actionPerformed you can try this:

private void actionPerformed(ActionEvent event) {
  // assuming that you have a list globally of type Patron (the super class)

  if (radioButton1 is checked) {
     // get from the desired fields the data and create a new instance:
     [B]newUnderGradPatron[/B]= new [B]UnderGradPatron[/B]();
    // set the values from the fields
    // add to the same list

  } else if (radioButton2 is checked) {
     // get from the desired fields the data and create a new instance:
     [B]newGraduatePatron[/B]= new [B]GraduatePatron[/B]();
    // set the values from the fields
    // add to the same list

  } else if (radioButton3 is checked) {
     // get from the desired fields the data and create a new instance:
     [B]newFacultyPatron[/B]= new [B]FacultyPatron[/B]();
    // set the values from the fields
    // add to the same list
  }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The phone[][] is null. That is why you are getting the exception.

And no this:

String phone[][] = { {"A", "B","C"},
       {"D", "E", "F"},
       {"G","H", "I"},
       {"J", "K", "L"},
       {"M", "N", "O"},
       {"P", "R", "S"},
       {"T", "U", "V"},
       {"W", "X", "Y"} };

Is not the same phone array as the one you are trying to access. The one you created is locally in the constructor. Your other methods can't see it.
when you are calling it form your code:

System.out.println("Element in [0][2]is: "+ phone[0][2]);

You are calling the one globally declared. You need to create that one in your constructor:

String [][] phone = null;

public TelePhone_Number_Word_Generator()
    {
       phone  = new String[8][3];
    
      phone[0][0] = "A";
      ...
      ...
    }
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I didn't quite realize your problem but here are some suggestions.

You can have one class with all the info and you can have one field indicating what type it is. You can have if-statements that check that field (type of patron) and display the data you want.


If you want to put different objects that extend the same class in the same list then here is an example:

public class Father {
    public Father() {

    }
    public String nameOfTheClass() {
        return "[ Father ]";
    }
}

public class Child1 extends Father {
    public Child1() {

    }
    public String nameOfTheClass() {
        return "[ Child 1 ]";
    }
}

public class Child2 extends Father {
    public Child2() {

    }
    public String nameOfTheClass() {
        return "[ Child 2 ]";
    }
}

Then the following code has 2 versions depending if you are using version 1.4 or newer.

Father f = new Father();
        Child1 ch1 = new Child1();
        Child2 ch2 = new Child2();

        [B]// You can add them to vector because they are all of type "Father[/B]"
        Vector<Father> v2 = new Vector<Father>();
        v2.add(f);
        v2.add(ch1);
        v2.add(ch2);

        [B]// here you get them from the vector and put them into "Father" objects[/B]
        Father f1 = v2.get(0);
        Father f2 = v2.get(1);
        Father f3 = v2.get(2);

       [B]// But when you print them[/B]
        System.out.println(f1.nameOfTheClass());
        System.out.println(f2.nameOfTheClass());
        System.out.println(f3.nameOfTheClass());

        [B]// The f2,f3 are actually "Child1", "Child2". You have access to the data of the Child1, Child2 classes but of course you can call only the methods …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

We need to see more code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I am not familiar with the classes of the javax.swing you are using but my experience tells me this:

Firstly, I assume that the method you use to add the book to the list takes as argument an Object class. That is OK because your Book extends the Object class and all of its methods.
But since it takes an Object as parameter it doesn't know the methods you have declared in your Book for displaying data.

But wait the Object class has a method that all classes inherit. That method is automatically called to display the data. But since you didn't override it, it returns what the original method returns: The name of the class followed by its hashCode value:
Book@b0f13d.

You know what is the method I am talking about don't you? It is the toString method.

Try this:
In a separate class create a Book instance in the main method, do this and execute that code:

public static void main(String [] args) {
   Book newBook = new Book (IDNum,Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN);
  
  System.out.println(newBook);
}

Then go to the Book class and do this:

class Book {

   public String toString() {
      return "This book: " + title + " was written by "+ author;
   }
}

And execute the above code again and see what happens.


Also the same applies when you put objects inside a List (Vector, ArrayList) and you try to print that list. It prints …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Check out the css tutorial at:
http://www.w3schools.com/css/default.asp

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You aren't making any sense

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

String.split()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If all u need is a code snippet for checking whether a given word is a palindrome, then use the one below:

I found interesting that code but noticed a few things that I didn't like:

while(left<right)
{
  if(word.charAt(left)!=word.charAt(right))
  {
     flag=0;
  }
  left++;
  right--;

  [B]if(flag==1)
  {
  System.out.println("The word" + word + "is a palindrome");
  }
  else
  {
  System.out.println("The word"+ word + "is not a palindrome");
  }[/B]
}

The bolded part shouldn't be in the loop.
Take this input: "abcdefgcba"
Because for the first checks it will print that it is palindrome, then it will keep printing that is not for a few loops before exiting.
You should print the result outside the loop, only once.
Also when the flag is set to 0 you can break from the loop because it is not necessary to continue checking. You found that it is not a palindrome so no need to check the rest of the word

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

To sumitlole.

NO, it is not the easiest way, it is the wrong way. This thread is 2.5 years old. What do you think you can accomplish.

In your code you have this:

System.out.println("Wrong Number Enter again");

if(s.charAt(0)==s.charAt(4) && s.charAt(1)==s.charAt(3))

You print the message "try again" but then you don't have a while loop for the user to enter again a value until the right one is entered. No matter the size of the input this code will be executed: if(s.charAt(0)==s.charAt(4) && s.charAt(1)==s.charAt(3)) which result to your program to crash.
Not to mention other little mistakes that make your code not safe to run

About your edit:
Use code tags !! Your code is difficult to read with all these colors

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because this:
123456789123
is not an int, it's a long.

It is a classic mistake when you try to use a big number. If you check the API you will see how big an int can be.

What value does this represent? Because we use int or long when we intend to do calculations with the fields.
For example if you want to save a phone number make it as String not an int.
If it is some key or id then you can put it to be long.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

saadismail85 please use code tags and/or start a new thread.
For code tags click the button: (code) when you write your post

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What kind of stored procedure. Do you know how to call that procedure from an sql editor?
I would suggest to use PreparedStatements or better:
CallableStatement.
For more info show what you have done so far.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

These lines are incorrect:

GetBookDetails();
newBook = new Book (IDNum, Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN);

with the GetBookDetails you get all the date from the gui, but when you call the "new Book" you "erase" the previous object and replace it with the new one. At the next lines the newBook doesn't have any of the values read because you did newBook = new Book and you created a new one with the default values that are declared at the class.

I think that this is what you want:

newBook = new Book (IDNum, Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN);

GetBookDetails();
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

can u please help me..please send me the code for that how to update the table using stored procedure in jsp program ..need it urgent

Start a new thread

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also it is best when you implement/override the equals method in your objects then you should also implement/override the hashCode method:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#hashCode()

There are many examples on how to implement it. There are many ideas. The more complex provide better performance when you put your objects into a Hashtable.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you run this code you will see that '==' doesn't work:

public static void main(String [] args) {
        String s1 = new String("aa");
        String s2 = new String("aa");
        
        System.out.println(s1==s2); // false
        System.out.println(s1.equals(s2)); // true
    }

The '==' checks if they are the same object and the equals their value. String is an object and you should treat it as such. Meaning that for objects if you want to check if they are equal use the "equals" method.

If you create an object of your own with private attributes/properties and you want to compare 2 of those then you should use the equals method. But since you wrote that class, you must implement/override the equals method.

Especially if you want to put that object in a List(Vector, ArrayList). The methods that they have for searching in the list, use the "equals" method of the object they contain. If you put java objects then that's ok because they already have that method. But for your own objects, your class must implement/override the equals method.

There is a code with action listener at the java gui where at the action performed method we use this '==' instead of equals.

private JButton butt = new JButton("Click here.");

public void actionPerformed(ActionEvent e) {
  Object src = e.getSource();
  if (src[B]==[/B]butt) {
     // button was clicked
  }
}

We use the '==' in this case because that method (getSource) returns the same instance of the object (the butt instance itselfm not …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

hey can u help me by dis problem
write down an application to display a window with various GUI components available in the awt packages

You revived an old thread, when the best advice would be to use the javax.swing package.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Whenever you do this:

return new BufferedReader(new InputStreamReader(System.in)).readLine();

you keep creating a new BufferedReader every time you call the method.
Not very efficient.
Try and have the BufferedReader as static and then use it form the static methods.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What java version are you using?
If you are using 1.5 for example then you can map the letters with the morse code using a hashmap:

HashMap<Character,String> map = HashMap<Character,String>(26);

map.put('a', ".-");
map.put('b', "-...");
...


String text = words.getText().toLowerCase();
char[] stringArray = text.toCharArray();

Then you can loop through the array and use the char as the key to get the String value from the map.


String result="";
...
result += map.get(stringArray[i]);
...
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That's because you don't read what I say to you. You just copy paste:

I changed this:

...
<option value='CONFIG_SOURCE' <%= ("CONFIG_SOURCE".equals([B][B]choice[/B][/B])) ? ("selected='selected'") : ""%> >CONFIG_SOURCE</option>
                <option value='CONFIG_PROCESS' <%= ("CONFIG_PROCESS".equals([B]choice[/B])) ? ("selected='selected'") : ""%> >CONFIG_PROCESS</option>
...

To this just to show you how the java is executed. (choice is replaced by the value taken from session)

<option value='CONFIG_SOURCE' <%= ("CONFIG_SOURCE".equals("[B]CONFIG_SOURCE[/B]")) ? ("selected='selected'") : ""%> >CONFIG_SOURCE</option>
                <option value='CONFIG_PROCESS' <%= ("CONFIG_PROCESS".equals("[B]CONFIG_PROCESS[/B]")) ? ("selected='selected'") : ""%> >CONFIG_PROCESS</option>

What you written will return true for all of them that is why you get always the same.

Put back 'choice' again.

Also why do you use the session. From your code whenever you submit, you change the value of the session.

If, and only if, the "currentTable" will be used for communication between these 2 pages then you can do this:

String choice = request.getParameter("tableSelect")

// rest of the code that displays the drop down list

I don't know the rest of your code, but if you want just to submit the value from one page to another then use only the request.
If you want that value to be seen from all the pages without having to submit; For example you went to a page from a complete different "path" and you want that value, then yes, put it in the session.