javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all remove all of the database code and put it in seperate methods and classes and call those methods from the jsp.

Then read the exception that you get. It tells you exactly what the error is at line 66
The NumberFormatException is thrown when you cannot convert something to a number:
Integer.parseInt(codigo)
And the stacktrace says: java.lang.NumberFormatException: null

You are trying to write some complex code with out knowing the basics. Handling NumberFormatException and figuring out that you are trying to parse something which is null is very simple. Especially since the exception tells you exactly that. I would like to suggest that you to take one step back.

Forget about jsps and jasper. Try to write simpler codes first and make a lot of mistakes. Seriously that is how you learn to read the stack trace and correct the errors that you get. By making them.

And by trying to execute queries in jsp is an indication that you haven't written many java core programs. Did you always put all of your code in the main method? Or did you have different classes with methods and call those methods in the main. You must do the same here. NO java code in the jsp unless they are used to displying the data or retrieve them and pass them as arguments to methods that do all the work

onosan commented: 0 +0
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all you don't initialize the Statement object. You have your connection and then you call the execute, but you didn't create the st.

Also everything you are doing is wrong. And don't tell me that it is correct because it executes. Don't open connection or run queries in a jsp. Have a separate method that returns true or false in a separate class. In the method you will open the connection, run the query, close the connection, which you don't, end return the result.
Then you will call that in the jsp.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster


Hi,

Exactly you catch my point. In html or javascript we can easily apply font colors by using <font> tag. But, i asking that how can we apply font colors in java to the specific text like "Contract". I need this text Contract appear as a blue.

If you aware of it, then please help along with code.


Thanks & Regards,

Jayavardhan. T

Like I asked: "Do you want to change the color of text in a Swing application?"
If yes, then I told you to look at the API of the components you are using to display your text.
You seem to know how to do it with html. But you failed to provide any useful information of what you want to do. Your question is very vague. And this thread has been getting too long with no useful information.
Can you post code showing where you want the color to be changed?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What is wrong with creating a class on your own? Like I suggested in one of your previous posts?

Anyway, even though it is wrong, you can do this:

Vector hotel = ....;
for - loop {
  Vector rmDet = (Vector)hotel.get(i);
  // now iterate the rmDet Vector.
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

yeah i am unable to locate the thing that is null, and the errors are inside the java fixed classes which i have in no way edited.

No you were too lazy to read the messages, as I told you. That is why you couldn't locate the error.:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.JComboBox.setModel(JComboBox.java:292)
at Application.UserManagement.initComponents(UserManagement.java:234)
at Application.UserManagement.<init>(UserManagement.java:52)
at Application.UserManagement$7.run(UserManagement.java:448)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 1 second)

Did I have to point that out to you? When you get any error, don't you even bother to read it, or just post the error and expect others to do it for you?

If you still can't fix it, then point out at the code where that line is. Although the problem is that you are using something which is null (you haven't initialized something) as stated by the exception and other posters:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public class Algarv {
    public static void main(String args[]) {
    int numbrid = 0; // Proovime kohe algusest
    int loendur = 0; // Loendame üles, et pärast lihtsam oleks
    while(loendur < 100) // Eelkontrolliga, t2idame kuni see on 100
        {
            numbrid++;
            if(numbrid % 2 != 0)
                {
                    int abi = 3;
                    while((numbrid % abi != 0)&&(abi <= ((numbrid - 1) / 2)))
                        {
                            abi++;
                        }
                            if(numbrid % abi != 0)
                                {
                                    loendur++;
                                    System.out.print(numbrid+" ");
									System.out.println(loendur);
                                }
                }
        }
}
}

For future reference, please have your comments in the code in English

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Para que se usa el string.value, ayudenme a crear una clase cuenta. Manda a pedir si quieres crear una cuenta de ahorro o una de credito...

Αυτό το thread είναι από το 2005. Αν έχεις να κάτι να πεις πόσταρε στα Αγγλικά.

Do you see how frustrating it is that I used my mother language?
> This thread is from 2005. If you have something to post, do it in English.
By the way the above is Greek. Ζήτω η Ελλάς. :)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Are you allowed to use these classes provided by java:
java.util.Vector
java.util.ArrayList ?
If yes then things are much easier

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The java way to do it is to create a class with attributes: CountryName, CountryID
Then create a method that runs the select-query, gets those values from the DB and puts them inside a Vector or ArrayList of that class and then of course return it.
Since you have the results you can do them whatever you want.
It is better to have separate classes that do stuff with the database and return the results. Then use those methods/results in any way you want. Don't mix inside the code queries that get the results and then manipulate them