Yes, loop the array and call the Math.pow for each of the elements of the array.
From what I see in your code, it is best to create a second array:
double fx [] = new double[x.length];
While you loop store each result to the new array
Yes, loop the array and call the Math.pow for each of the elements of the array.
From what I see in your code, it is best to create a second array:
double fx [] = new double[x.length];
While you loop store each result to the new array
I have tested the code and for the first version, the students are saved successfully. The problem occurred when I closed the application and run it again. The old students where replaced by the new entries.
I tried creating the FileOutputStream like this, with no luck:
outputStudent = new FileOutputStream("Student.txt", true); // check the API
So I would suggest when you start the app, to read all the written students and to rewrite them before adding new ones. It is better for this case not to save Student objects but one Vector object:
private Vector<Student> students = new Vector<Student>();
public void actionPerformed(ActionEvent e)
{
Student empCurrent = new Student(txtStudentName.getText(), ... ,...);
students.add(empCurrent);
txtStudentName.setText("");
txtAddress.setText("");
txtResults.setText("");
txtStudentName.requestFocus();
}
public void windowClosing(WindowEvent event)
{
objSaveStudent.writeObject(students);
closeStream();
System.exit(0);
}
PS: At the empCurrent variable, what does the 'emp' stands for?
Ok. No I haven't, is there anyway to create a new file each time you try write?
In order to be able to write using ObjectOutputStream you need this at the object you are trying to write: implements java.io.Serializable
If that object has other objects as attributes those object also need to implement the same. Some java object also implement that interface such as the java.lang.String object. Which is why you can write your Student object. For primitive types (int) you are ok.
If you want a different file then with button click, you will need new FileOutputStream and ObjectOutputStream objects with file you want. You will need to close them as well.:
FileOutputStream fos = new ....
ObjectOutputStream objSaveStudent = new ....
Student empCurrent = new Student(txtStudentName.getText(),
txtAddress.getText(),
txtResults.getText());
objSaveStudent.writeObject(empCurrent);
// close them
I think that if that you can save multiple objects in one file. But when you read you will have to call the readObject method multiple times as well. If you don't know how many just keep calling it until you get an Exception. Then catch it without doing anything and continue with the code.
Next time use the button (code) when posting code and put it inside the tags.
Question: Have you implemented the java.io.Serializable interface?
Have you been given a formula for the above calculations because they are not java related and not all people know them, But they can write the code once they are provided.
Actually I have written a program that times those 2 methods and the String.valueOf() method is much faster than the other:
Try this code:
int N = 1000000;
long time = System.currentTimeMillis();
for (int i=0;i<N;i++) {
String a = ""+i;
}
time = System.currentTimeMillis() - time;
System.out.println(time);
time = System.currentTimeMillis();
for (int i=0;i<N;i++) {
String a = String.valueOf(i);
}
time = System.currentTimeMillis() - time;
System.out.println(time);
The String.valueOf() creates 1 String. But the '+' symbol: "" + 5
, creates 1 String: "" and then when the '+' is applied it creates one more String which is the result.
You have been given the code that does what you want. You have been told the '%' remainder operator:
if(userNum % 2 == 0 ){
System.out.println("The number "+userNum+" is even");
}
else{
System.out.println("The number "+userNum+" is odd");
}
The challenge was for you to write the code, not us. Since you have been doing java for 2 weeks and you have been told how to find if a number is even or odd, then you should be able to write the program that you want on your own.
Post your code, which is something we haven't seen yet, and ask questions about it.
Although I doubt we can say anything more than what has already been said since you have been practically given the answer.
Well your suppose to show some of your own work but here's the method for that problem. You will have to create the main method yourself if you want to implement it.
public static int findMax(int a, int b, int c) { if(a > b && a > c){ System.out.println(a+" is the largest number"); return a; }else if(b > a && b > c){ System.out.println(b+" is the largest number"); return b; }else System.out.println(c+" is the largest number"); return c; }
Nice attempt for a good reply, although I dread to think what will happen when Eman1 is asked to find the max or min not from a total of 3 numbers but from a list of N numbers.
Try to give answers that enable the poster to write some code in their own.
In case you haven't found it:
String [][] menuInput ={{"File", "Edit", "Windows", "Help"},{"Open","Cut","First","About"},{"Close","Paste","Second", null},{"Exit","Copy",null, null},{null, "Select All", null, null[B],[/B]}};
I think it is the extra ',' you have at the end:
{null, "Select All", null, null,}
Why don't you try this simple thing:
String input = "";
double number = 0.0;
boolean goodNumber = false;
while (!goodNumber)
{
input = JOptionPane.showInputDialog(null, USER_LENGTH, null, JOptionPane.QUESTION_MESSAGE); // request length
try {
input = input.trim();
number = Double.parseDouble(input);
goodNumber = true;
} catch (NumberFormatException nfe) {
goodNumber = false;
// INVALID NUMBER
} catch (Exception e) {
goodNumber = false;
// INVALID INPUT
// I don't remember the API of the JOptionPane. This is in case the input.trim() gives you a NullPointerException
}
}
<% String user=request.getParameter("LedgerName"); ResultSet rs=st.executeQuery("SELECT RoomMasterID,RoomNo FROM RoomMaster AS RM, LedgerMaster AS LM WHERE RM.LedgerID = LM.LedgerID AND LedgerName = '" & Me.datRoomType.SelectedItem.Text & "' AND RM.Status <> 'NO' AND RoomMasterID NOT IN (SELECT DISTINCT RoomMasterID FROM BookingMaster WHERE ' " & Me.datarrivaldate.AmericanDate & " 'BETWEEN FromDate AND ToDate) AND RoomMasterID NOT IN (SELECT DISTINCT RoomMasterID FROM BookingMaster WHERE ' " & Me.datdeparturedate.AmericanDate & " ' BETWEEN FromDate AND ToDate)");
Is this javascript or java:
AND LedgerName = '" & [B]Me.datRoomType.SelectedItem.Text[/B] & "'
?
thanks for your help, and by the way how do i call a method? can you give me an example? Thnka :D
If i use the args[] then i will only be able to enter 1 value, i need 3, and i don't know what "scanner" is, my teacher didn't teach me that yet so can you be more specific about this scanner thing? Thnaks
You will be able to enter as many values as you want with args. It is an array:
public static void main(String [B][][/B] args)
Console:
> java YourMainClass 1 2 3 4 5
The args array will have length the number of arguments you enter. And its elements would be the values entered.
As for calling methods, your teacher wouldn't have given that assignment if he hadn't teach you that. Look at your book or notes.
And it is difficult to help without knowing what you know. If you don't know the Scanner class what has your teacher told you?
Maybe you should start by hard coding 3 values to the code and continue from there:
int a = 5;
int b = 6;
int c = 3;
// the rest of the code
This is the problem
if(ah.hasNextDouble())[B];[/B]
When you add the ; it ends the command. Meaning that you ended the if command. Meaning that the rest:
{
}
Weren't "connected" with the if. It was like writing this:
if(ah.hasNextDouble()) {
}
{
w=ah.nextDouble();
x=ah.nextDouble();
y=ah.nextDouble();
....
}
Scanner class for reading input from keyboard. Search the forum for examples or look the API.
Or, use the args[] and enter the values from the command prompt.
If statements to check if it is between 0 and 100 and print error message and return.
One class will have a method that takes as arguments those 3 numbers and execute the comparison.
The other class will read the numbers and call the method of the first class with those numbers as parameters.
Check the API for the PrepareStatement class. There is something called: setNull(int, int) . The first argument is the index of the '?' and the other the type of the column.
Assuming that col2 is type of NUMBER at your database table then you can do this:
pstmt.setNull(2, java.sql.Types.NUMERIC)
instead of this:
//pstmt.setInt(2,null);
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html#setNull%28int,%20int%29
i dont want any reply from big peoples lik u... i expected it frm person who willing to help to anybody..
And what kind of help would you want? Someone to code it for you? What didn't you like from the previous post?
It is true that we are not obligated to provide solutions immediately the moment someone posts a question. Our lives don't resolve around answering your questions. We are not under your payroll. We also have jobs with deadlines to meet
If no one has answered could mean a million things. I personally don't know how to fix what you want.
And the link provided might help you.
If you didn't understand it then ask a question about it.
PS: Peter can you check the link because I could not open it. I don't know if there is something wrong with me or the link.
I assume for testing you have something like this:
String username = ... ; // taken from gui
String password = ... ; // taken from gui
if ((username.equals("hard code value"))&&(password .equals("hard code value"))) {
// SUCCESS
}
I would like to add that If you don't want to use a database then this:
2 basic arrays, a 2-D array
would be not a good idea.
Create an object User with attributes username, password and an equals method. Then have a list of those objects somewhere stored and when the user logs in create a User object with those values and search the list.
Have you considered using:
while(hasNextDouble)
Do you have somewhere the usernames and passwords stored? If yes when the user enters username amd password compare those values with the ones you have saved.
Hi javaAddict,
Thanks for your reply. But what if the case like user selects multiple rows to delete ?
Thanks in advance,
Chandu
I am not very familiar with the API of JTable, but if you find a way to select multiple rows to delete then you should be able to find a way get all those ids. Then execute multiple deletes to the database or just one using the IN sql keyword.
As for the sequential index, you can still loop all the rows of the table an update the column
Because you declare it twice:
[B]String[/B] name
do
{
[B]String[/B] name = ..... ;
}
You declare it once outside the loop and use it like any other variable:
String name = "5";
name="asdfasfd";
name += "ssss";
Also you must add a ';' at the end of the declaration and initialize it. Otherwise you will get a NullPointerException.
Also use the equals method for comparing strings:
while (name.equals("erin"));
I don't believe that the database should be updated. Especially if that column is a Primary Key linked with some other table.
For the JTable:
When you click the row, you can get the selected row index. That is sequential. When you delete it that value that you have saved in a variable is the index of the next row. So you can write a loop from that index till the end where you take each row and reduce by one the value of the column you want.
If you want to update the DB, while you are looping take the primary key of the row from the JTable and update the DB table
ok ok!.. i'm new in here and i don't know the rules.. so i suggest to place some guide rules on your site before you say something bad.. tnx!
The links provided by BestJewSinceJC were on top of this forum and every forum for everyone to read. It is easy to see them.
And did you honestly think that there is site that does other's people homework just for free and every one could post their assignments and the members of this forum would send the solution to anyone has asked for it? Does this sound logical?
ok i'm sorry.. i'm not lazy ok??.. thanks for your reply..
If you are not lazy then post your initial code and we will help you correct it and solve your problem. But don't expect someone to write this thing for you and send it.
Filename: CommonLetters.java
Problem Statement:
Write a program that takes two words as input and finds any common letters that they have. For example, the words ‘computer’ and ‘program’ have the letters ‘o’, ‘m’, ‘p’, and ‘r’ in common. The input to the program will be a string which contains two words consisting solely of lowercase alphabetic characters and separated by a single space. Output the words with all common letters capitalized.Sample Output:
Input two words: COMPUTER program
Output : cOMPuteR PROgRaMplease send me the codes using String.. guys i need your help..
here is my email add.:
[email]<<Email Snipped>>[/email]tnx!
This is a 5 year old thread. Start a new one. And keep in mind that:
We do not send mails with codes to people and we do not do their homework for them.
Show your code and ask for questions about it.
COMMAND LINE:
> java YourClass arg1 arg2 "arg3 arg4"
public class YourClass {
public static void main(String [] [B]args[/B]) {
System.out.println("Number of Arguments: "+[B]args[/B].length);
for (int i=0;i<[B]args[/B].length;i++) {
System.out.println([B]args[/B][i]);
}
}
}
The arguments at the command line are passed in the args array. If no arguments given, it has length 0. It is never null.
The above will return:
Number of Arguments: 3
arg1
arg2
arg3 arg4 // this is the third argument. The double quotes allow you to have spaces inside an argument
Use for loops, take a look at the String class API, use the '%' operator, post code
If it throws NullPointerException then something is null. Look at the error message to find the line that this happens. Then try to print the values of the objects used to see what is null.
At what line you get that error?
1) You don't initialize the DAO object, you only declare it so it is null.
2) The DAO requires only 1 constructor with no arguments. Because everything that is needed for the opening of the connection are declared inside it.
3) Don't do that:
dataList.add(rs.getString("zId"));
dataList.add(rs.getString("p"));
dataList.add(rs.getString("oP"));
dataList.add(rs.getString("CSFare"));
Simply create a class with those as attributes: zId, p, ... and instantiate it:
Ticket tick = new Ticket(rs.getString("zId"), .....);
dataList.add(tick) ;
Also since your query is like this:
"SELECT zoneId,peak,offPeak,cashSingleFare FROM ticket"
You should be doing this: rs.getString("zoneId")
4) Close the ResultSet.
5) Don't close the out writer. You don't even use it, so you don't even need to call it.
The push method should be:
if (top == store.length-1)
throw new StackException("Stack's underlying storage is overflow");
top++;
store[top] = value;
Because initially top is -1. The you increase it and use it as index. Meaning that top will hold not the number of elements but the index of the last value entered. Meaning that the maximum value that it will take is store.length-1.
Imagine an array of size 3. You enter the last element at place 2: store[top] = value;
Top is 2.
Then you call push again: if (top == store.length)
. This will be false because size is 3. Then topp will be increased from 2 to 3 and then it will be used as index, which will give you an error.
The rest methods are OK. Also you should add an isFull method.
As for your question, just create a main method in this class or another. It doesn't matter where is created. When you call the class, only the main method will execute and everything that is inside it.
In that main method, create an instance of the object MyStack and call its methods with various arguments. For better demonstration, try to add more values than the Stack can handle in order to show how you can catch the exception.
The while takes as "argument" a boolean expression. So why don't you use a boolean.
At first have it to be true, so you will enter the loop. If the user enters correct String that can be converted into a number, meaning that this: Integer.parseInt
will execute, make that variable false. That will make the loop exit
It's actually quite ridiculous my code snippet got voted down twice the other day also -- I think it's just incompetent users randomly voting things down they don't immediately understand because they are java noobs. I don't think it's something to really worry about. And... I'm guessing this post will be voted down too ;)
I don't believe it is because they don't understand the code, but simply because they are just bad and mean. But I will have to agree with the randomness thing.
Also since this is getting way out of topic I suggest we stop here discussing about it. At the DaniWeb Community Feedback forum there is a thread there you can contribute.
Ok this is serious and somebody should do something about it. I just saw that need, the poster who created this thread got down voted, twice!
I would like the @#!@$!@$# that did this to post here and explain the reasons. Because people get down voted for no reasons when they have very good posts, or posts that violate no rules, such as this one.
Why was the fist post down voted?? Are you man enough to show yourself and explain why?
I would suggest to write a method that takes as arguments the array of Students and a Student object:
boolean static int indexOf(Strudent [] array, Strudent st) {
}
Loop the array and see if the array contains the Student st. If found, immediately return the index where that student is. If you finish the loop without returning, means that you didn't found the student, so return -1 at the end:
YOUR Code with mine:
//StudentTest
import java.util.Scanner;
public class StudentTest {
public static void main( String[] args)
{
Student[] students = new Student[2];
Scanner inputs = new Scanner(System.in);
for(int i = 0 ; i < students.length; i++)
{
System.out.println("Please enter Student Number");
String fName = inputs.nextLine();
System.out.println("Please enter Student First Name");
String lName = inputs.nextLine();
System.out.println("Please enter Student Last Name");
String sNumber = inputs.nextLine();
// NEW CODE ///////////////
Student st = new Student(fName, lName, sNumber);
if (indexOf(students, st)==-1) {
// New Student
students[i] = new Student(fName, lName, sNumber);
} else {
System.out.println("Student: "+st+", already exists");
i--;
}
// NEW CODE ///////////////
}
for(int i = 0 ; i < students.length; i++)
{
System.out.print(students[i].toString());
}
}
boolean static int indexOf(Strudent [] array, Strudent st) {
// TODO
}
}
Be careful in that method to make sure that you don't compare any null objects. The array when initialized has null values as elements, so I would suggest something like this: st.equals(array[i]);
instead of array[i].equals(st);
Also for the above comparison you must use the equals method. For that …
you can do that without a loop. there is a formula I dont remember. however, here you have the code with the loop.
public class Interest{ public static void main(String[] args){ double x = 0; for(int i = 1; i<4; i++){ x = (x +100) * 1.00417; } System.out.println(x); } }
Giving code is against the rules especially when the poster said that the problem was solved
public class Person { public String Name; public String SocialSecurityNumber; public String PhoneNumber; public Person(String name, String socialSecurityNumber, String phoneNumber) { Name = name; SocialSecurityNumber = socialSecurityNumber; PhoneNumber = phoneNumber; } @Override public boolean equals(Object compareObj) { if (this == compareObj) // Are they exactly the same instance? return true; if (compareObj == null) // Is the object being compared null? return false; if (!(compareObj instanceof Person)) // Is the object being compared also a Person? return false; Person comparePerson = (Person)compareObj; // Convert the object to a Person return this.SocialSecurityNumber.equals(comparePerson.SocialSecurityNumber); // Are they equal? } @Override public int hashCode() { int primeNumber = 31; return primeNumber + this.SocialSecurityNumber.hashCode(); } }
Hope this code may solve your problem
How could that solve his problem? Not to mention that you will get a NullPointerException with that code.
Dmith post the error that you get as well as relevant code.
Sorry About that im new to this website so i thought the down arrow meant to go to the next post and i was trying to undo it but don't know how. if you can let me know how ill undo that. Sorry once again and thank you for your help!
Once someone votes a post they cannot vote again. If that was possible anyone could give thousands of positive or negative votes to anyone. That would cause a lot of mess.
Thanks so much !
Another thing i dont get is that the hashtable stores plane objects (dont ask) i wrote some code that iterates through the table, how can i access some of the variables for the plane object? i have get methods for it. Sorry this key thing confuses me.
Plane plane = new Plane();
Hashtable<String, Plane> table = new Hashtable<String, Plane>();
table.put("keyPlane1", plane);
....
Plane p = table.get("keyPlane1");
p.getName();
p.getSeats();
p.getNumberOfEngines();
...
table.get("keyPlane1").setName("Boing 777");
In case the you are using a key that doesn't exist in the table then you should always do this just in case:
Hashtable<String, Plane> table = new Hashtable<String, Plane>();
table.put("keyPlane1", plane);
Plane p = table.get("keyPlane2");
if (p==null) {
System.out.println("keyPlane2 doesn't exist");
} else {
system.out.println("Plane found: " + p);
}
Look at the API for Hashtable
Are you saying that you saved the images to a file, then changed the class and then tried to read? If yes then Yes you will not be able to read them because:
You serialized instances of this: SerializableImage. the files containes this: SerializableImage.
But whan you read them you are trying to pass that to a: myPackage.SerializableImage instance.
This will compile:
myPackage.SerializableImage image = (myPackage.SerializableImage)readObject();
But if the read object doesn't return an myPackage.SerializableImage object the program will crash. And the files contain SerializableImage objects.
So you will have to serialize the images again. Or for a more "professional" solution: Write a prgram that reads all the files and saves them into a SerializableImage. Then use the values of those objects to create mypackage.SerializableImage objects and save those by replacing the old files. you will have to do the above only once and the files will work from now on.
your should create your comparator class by implementing Comparator Interface.
Once you do it, then you can create your hashtable as follows:
private Hashtable<String, Planes> planesFlying = new Hashtable<String, Planes>(new YourMapComparator());
something similar to this.
That is COMPLETELY gangsta1903 wrong. If you don't know java don't give wrong advices. Where did you see that constructor:
private Hashtable<String, Planes> planesFlying = new Hashtable<String, Planes>(new YourMapComparator());
Here is the solution.
Do you want to sort this out based on the key (String) or the values (Planes)?
If you want it based on the key then look at the API for the Hashtable class. There should be a method that lets you take the keys as a collection (Set<K> keySet() ). Use the toArray method of that Set to create an array. Then you can use any algorithm you want or you can use the sort method of the java.util.Arrays. You don't need to implement the Comparable interface since the String class already does that.
After the array with the keys is sorted you can loop that array and use each key to get each plane from the Hashtable.
I would like also to add that it is not a good idea to to use Hashtable if you want them sorted. You'd better use a Vector to put your Planes and have the "key" as part of the Plane's class attribute. If you do that you will have to implement the Comparable class. Check the derscription of this:
we don't deliver custom made code ...
I provided you with some logic you could follow, if you know how to create a checkbox and how to work with arrays, you should be able to try that
He is right. When you run the query save the results in list or an array. Then loop that array and create with each loop a different checkbox. Then use those checkboxes in any way you want.
Also if you are using a GUI builder for your gui then it will not work for a variable number of checkboxes
They both do the same thing it doesn't matter which one to use.b Whether you pass the value of B to the A through the constructor or not it the same:
1.
B bInst = new B();
bInst.num = 10; // here we are referring to the num of B
A aInst = new A();
aInst.obj_B = bInst;
aInst.num = 5; // here we are referring to the num of A
Or
2.
B bInst = new B();
bInst.num = 10; // here we are referring to the num of B
A aInst = new A(bInst );
aInst.num = 5; // here we are referring to the num of A
They both do the same thing.
Of course you will have to make them public (obj_B, num) or declare get/set methods in the A class for the obj_B and the num
It is because that method doesn't exist (readUTF) when you call it like this: readUTF();
Now if that method was part of another class, like DataInputStream then maybe you should have done this:
input = new DataInputStream(new FileInputStream("11192007"));
acctNum.setText(input.readUTF());
Also check the API for DataInputStream and FileInputStream. If you get any other errors refer to them and see what arguments the methods you are using take and what they return
I think it is because when you call the super constructor, you have to pass values to it as parameters. In order to get the first the first argumnet this needs to be called:
super([B]getGuideName[/B]() + (++openFrameCount), true, true, true, true)
Meaning that when you do the above it is not the constructor that is called first. First the getGuideName is called in order to get the guide name, and then super is called with that value. And the super constructor always needs to be called first.
post code
Apparently giving good advices and suggestions on how to solve one's problem is a reason for down voting in this thread.
And I am referring to my previous post
First create a class name Fan.The class contains:
Three constants named SLOW, MEDIUM, and FAST with values 1, 2, and 3 to denote the fan speed.
An int data field named speed that specifies the speed of the fan (default SLOW).
A boolean data field named on that specifies whether the fan is on (default false).
A double data field named radius that specifies the radius of the fan (default 5).
A string data field named color that specifies the color of the fan (default blue).
A no-arg constructor that creates a default fan.
The accessor and mutator methods for all four data fields. (get and set methods for all your variables)
A method named toString() that returns a string description for the fan. If the fan is on, the method returns the fan speed, color, and radius in one combined string. If the fan is not on, the method returns fan color and radius along with the string "fan is off" in one combined string.
The only help we can give you is the above. Because that description tells you exactly what you need to do. You don't have to think anything. It is not like you have been told to create a Fan class and you had to think the rest for yourself.
You have been given everything you need to code this. Just do exactly what the instructions tells you to do.
If you don't know …
I didn't notice the requirements. And you have already been given the signature with this description:
return The Lot with the given number, or null of there is no such lot.
Also the requirements say:
param number the number of the lot to be removed.
Meaning the parameter will not be the position of the lot in the list. When you do this remove(number) you remove the lot which is at the position number.
But what you have been asked is to remove the lot with the given number:
public class Lot
{
// A unique identifying number.
private final int number;
..
}
Meaning that in your method, you will need to loop the list. Take each Lot and compare its number with the one given. If they are equal you have found it and return immediately. If the loop finishes without finding anything, then such lot doesn't exists so outside the loop return null;
loop the list {
take the Lot
if (Lot.number == number) {
// Lot found and you must return it AFTER YOU REMOVE IT using the remove method you have been using.
// only now remember that the parameter of the remove method is the index of the Lot in the list. And now you know the position of the Lot
}
}
// if you haven't returned yet then just return null because you haven't found anything
Suppose you save $100 each month into a savings account with the annual interest rate 5%. So, the monthly interest rate is 0.05/12 = 0.00417. After the first month, the value in the account becomes
100 * (1 + 0.00417) = 100.417After the second month, the value in the account becomes
(100 + 100.417) * (1+0.00417) = 201.252After the third month, the value in the account becomes,
(100 + 201.252) * (1 + 0.00417) = 302.507
and so on.
Write a program to display the account value after the sixth month.
It seems to me that all you need is a for loop:
(100 + 0) * (1 + 0.00417) = 100.417
(100 + 100.417) * (1 + 0.00417) = 201.252
(100 + 201.252) * (1 + 0.00417) = 302.507
The (1 + 0.00417) repeats itself so you don't have to worry about it. Everything else is the same. The new result would be if you add to the old one the 100 and you multiply it by (1 + 0.00417).
result = (result+100)*a; Where a = (1 + 0.00417)
Just put that in a for loop.
try this one:
1) capture the value of the dropdown select box with javascript using the getElementById command.
2) then next step to do is simply pass the value captured to the servlet. thats all! its gonna work! I guarantee you!
First of all this thread is 5 years old.
Second what you said is not necessary for the solution. The html code is correct and all is needed is to submit the form. You don't need javascript in order to put the value to another field and send that.
If you have read the entire you would know what was the problem.
And it is time to close this thread, before another tries to post their own crazy idea.