stephen84s 550 Nearly a Posting Virtuoso Featured Poster

<EDIT> Ignore please ............. mixed my tabs again :@

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Just a thought, instead of writing each object after serializing one by one to the file, why don't you just serialize the entire ArrayList and write it to a file.
And when you need to add any data to the file, get the ArrayList back from the file, add the object to the ArrayList and serialize this ArrayList overwrite the older file with the file containing the new ArrayList

Alex Edwards commented: A nice idea - Serialize the objects in a collection (though I disagree with using ArrayList in this case @_@ ) +5
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I tried your code by running it (with a few changes like extending JFrame instead of JPanel, adding a main to make it run as a stand alone), and it worked.
Its converting the temperature correctly when I click on the buttons also.

So whats the problem ????

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Your button "output" doesn't work cause you haven't added an ActionListener for it like your JTextField

Also you have just one JButton object named "output" and you are first initializing here :-

output = new JButton ("Convert to Celsius: ");

and then overwriting it a few lines below here:-

output = new JButton ("Convert to Fahrenheit: ");
results_c = new JLabel (" ");

So sort out which initialization do you need.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Try creating a hidden field in your form with the name "tid" and assign it the value you wish it to hold and then set the action field of the form to only http://localhost/rentry.asp .

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Amazing I found the exact problem solved right here and then you may look here and here.

Ezzaral commented: Exactly the answer he needed. +12
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Added.......
retrieving values using the code on another jsp page.
thanks

From that anyone will assume the query was solved and one of the moderators might have marked it as solved.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well if the problem was solved then at least mention how it was solved, and mark the thread as solved so other people can use it.
Even previously I have noticed you just do not mention how a certain problem was solved, unless explicitly asked. Its not exactly fun to help such people.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Try checking out request.getParameterValues() method, It should fetch you all the values even if some of the input elements have the same name.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You **have not** pasted the code which is causing the problem or just displaying one record.
Right now I am just shooting in the dark here and assuming the problem lies in this piece of code, if it is inside the while loop :-

<input type="text" name="id" value="<%=id%>" size="4">

It is considered a bad practice to have multiple input elements (except radio buttons, check boxes) to be given the same name or ID.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
public static void main( String args[] )
     {
       public String productName;  // product name
       public double number;  // product item number
       public double units;   // number of units in stock
       public double price;   // price per unit
       public double value;   // total value of all units in stock

You use the access specifiers (public,private, protected) only for Class level variables, not for local variables, I suggest you please get a good book and clear out your basics of Java.

Alex Edwards commented: Cut him some slack =P +4
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Can you suggest some easy reading on concurrency (I like reading in style of Deitel or OReilly books, explanation with plenty of examples to try out)

Well I don't know if this would be an overkill (especially if you just need to start up) but when it comes to concurrency, I liked Java Concurrency in Practice By Brian Goetz

Alex Edwards commented: Indeed, a very good book. +4
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Finally because of the fan fare I decided to give Chrome a go today. . . . . AND HELL I was disappointed, Flash took ages to load, sites like Orkut and Facebook wouldn't behave properly, no way to organize your favourites ... At least I couldn't find any, heck I guess Firefox and IE don't have too much to worry about (from chrome) for some time to come !!!

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Is there a way to close one frame only?

Check out the dispose() method of the JFrame class.
You can also check this tutorial to learn more about Event Handling in Java.

The second question you mentioned is related to the concept of anonymous inner classes, but if you are beginning in Java then I suggest for now you stick to the method mentioned in The Java Tutorial which is my first link.

And please use [code] tags to post your code. Look here and here for more information of code tags

darkagn commented: Well explained :) +3
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Uhmmmm, I believe the contentPanes of the top-level windows use BorderLayout, but that's beside the fact.

Grrrr :@ ........ yep that's correct :) !!!

Glad at least we agree on the tutorial he should use and about the null layout.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You have not set the layout for your JFrame, and so it is using the FlowLayout.
And from your code it looks like you want to use the NULL Layout (something like what VB offers).
Refer to this tutorial from Sun to learn about Layout Managers in Java.

Also I suggest you do not use the NULL layout cause then Java cannot rearrange/resize your components depending on the User's screen size / resolution.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

First run Peter's Query in your DBMS and see how the results are displayed.

Next if your JDBC concepts are good go to my second link first (the one pointing to the javadocs of the ResultSet interface).

If the answer still doesn't click, then I guess you will need to go through the tutorial till you get what you want.

Trust me if you find and correct these small mistakes yourself, you will know how to go about larger problems.

Also I will tell you where you are going wrong you are expecting all the three parameters for SL,PL and CL in one row like:.

PL     CL     SL
30     7     7

Whereas when you run the query given by Peter attached with the order by clause as shown here:-

SELECT m_leavetype, m_bal 
FROM TABLENAME
WHERE m_emp_no='1004' ORDER BY (m_leavetype);

Note the use of the order by clause to force the database to sort the way the records are stored in your ResultSet so that you will always get "cl", "pl" and "sl" in that order in your ResultSet and not in the order their rows were inserted.
You would get three rows like this:-

m_leavetype            m_bal
 cl                     7
 pl                     30
 sl                      7

So you have to just change your code to search for CL,PL and SL vertically rather than horizontally(i.e in one row).

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well welcome to the World of Software Development then, and as far as JSP/Servlets basics are concerned if you would have just look a couple of threads below is a thread mentioned JSP How to Start. That should help you get your basics up in JSPs and servlets.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

That shows that you have not put in an effort to go through either of my links, why should I help you then, for a guy of average IQ that should be no more than an hours work and what guarantees that you will go through the tutorial when you no longer need it.
The major reason I am not revealing the mistake is cause the mistake is too simple.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

start quote:

while(rs.next());
{
balance bal = new balance();
bal.setpl_bal(rs.getString(1,"m_bal"));
bal.setsl_bal(rs.getString(2,"m_bal"));
bal.setcl_bal(rs.getString(3,"m_bal"));

bal1.add(bal);
}
con.close();

If i am doing anything wrong pls correct me.

Yes you are doing this completely wrong.
Have you tried running the query Peter gave directly in your DBMS ?
It gives you three rows(CL,PL and SL) with two columns (m_leavetype, m_bal).
and if you add an extra order by clause you will get you CL first then PL and finally SL.

Although I can give you the code directly but I think redirecting you to the JDBC tutorial would be more helpful for you.
http://java.sun.com/docs/books/tutorial/jdbc/

Cause there you will learn how to actually extract the data from the query and most probably not need our assistance on it any more.

Also check out the javadocs for ResultSet Interface. You may figure out what you are doing wrong there.

Also please use code-tags while posting code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well first lets start with the Operating Systems, there are a ton of free operating systems (better known as linux dstributions) based on Linux, Here are a few popular ones:-

Debian A popular free linux distro.
Ubuntu These guys actually ship Ubuntu CDs directly to your home without any charge whatsoever. Also it is one of the most popular Linux distributions available with excellent support. Ubuntu is based on Debian.
OpenSuse OpenSuse was developed by the Suse group initially now acquired by Novell. OpenSuse has the best desktop, in all the linux distros I have ever seen and is the OS I am using while writing this.
Slackware This is the oldest surviving distibution of linux, but this recommended for experts as you will have mostly hand edit configuration files in this distribution.
Gentoo Gentoo is also a nice operating system with a mature desktop environment. It also based on Debian.
Fedora This based on Red Hat Linux, in fact it is supposed to be the testing distro for features that will be later incorporated in to the Red Hat Enterprise Linux OS which is a free software but not free of charge. Fedora is an RPM based distribution.
Mandriva Mandriva was the first distribution that got me hooked on Linux, before I had tried Red Hat Linux 9, but later was disappointed with it and had gone back to Windows, it was Mandriva that …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I have seen the same happen to many sites including Yahoo and GMail, and it happened on both browsers IE6 and Firefox,
The situation in which this happened was the page was taking too long to load (mostly due to a slow net connection) and suddenly in between the connection drops or we manually stop the page from loading.
I am guessing the browser managed to download all the text / html components and was downloading the images,css etc when the connection was interrupted, so it ended up displaying the text/html components alone, I arrived at this conclusion cause in "lynx" which is a text based browser, daniweb looks pretty similar to what is shown in the screenshot.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Honestly I was just shooting in the dark, Even I think your(Peter) first post answers the question asked(at least what I thought he was asking) perfectly.

now i want to display the m_bal for pl,sl,cl in the jsp page for the respective userid who has logged in.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Come on Peter use your Crystal Ball to identify the Error !!! ;)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Peter's query would give you three rows each row indicating how many leaves left of that particular type for the given employee. From your posts .. even the last one I feel you needed that.
However in case you just need the total number of leaves left for an employee you could use

SELECT SUM(m_bal)
FROM TABLENAME 
WHERE m_emp_no='1004';

The above would give you for just for one employee, in case you wish to get back the balance of leaves for all employees, you could use:-

SELECT m_emp_no,SUM(m_bal) 
FROM TABLENAME
GROUP BY (m_emp_no)
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Mark the thread as solved please ... I wanna increase my solved threads count :P

Alex Edwards commented: Well if he forgets to do that, I'll at least give you the rep =P +4
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Although I haven't used it, have you tried public void addSelectionInterval(int index0,int index1) in the DefaultListSelectionModel class.
Also have you set the selection mode to MULTIPLE_INTERVAL_SELECTION .

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Laziness, the worst illness of humankind.

especially considering the fact that the JDK comes with quite a few good examples !!!

@ thread starter
Have you ever browsed the installation folder of your JDK ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I understand that so how can I rectify that and how come if I had only two classes i.e Chapter and mainPrg it would have been able to access it? (Am basing this on the fact that I have tried the latter and it seems to work)

Sorry but that is not possible, you just haven't declared the said method in the Chapter class, So it doesn't take a java compiler to tell that you have an error there.

Most probably when you are working with only two classes you must have also deleted the code on line 119 and so might have not got the error.

Also here is link on conventions used while writing code in Java.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

chptobj1 is an object of class Chapter , whereas printInfo() is a method of class Book . So definitely Java can't find printInfo() method in the Chapter class.

It should have been bkobj1.printInfo() , But you should be able to trace and solve such errors on your own.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

normally no, username maybe, but from a little I had read, some may contain your sessionId etc.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Try using session.setAttribute() / session.getAttribute() instead of request.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Ok got a solution to your problem here with just a little googling.

It says to install the libc6-dev package.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well can you tell us what you are trying to achieve here actually, I don't have much to go on from what you have posted !!
crt1.o looks to be an object file and it seems like your linker (ld) can't find it, but what are you actually doing when this error arrives would help us get a clearer picture.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

No point to repeat that, this guy completely ignore that for last two weeks from me. Another hopeless case to bang on...

yep ..... you have one witness here, who saw it first hand !!! ;)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

That would be as simple as calling request.getParameter("--name-of-text-box--"); , in pagina2.jsp .

Also no need to stick to GET you can use POST without any issues. Only difference is GET would send your parameters as part of the HTTP URL (eg http://localhost/pagina2.jsp?usuario=tefbaez)
whereas POST would send it as part of the HTTP header, so it would not be visible in your address bar.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Have you tried what I had mentioned in my previous post ?????

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
public static void changePerson(Person p) {
         p.setName("GHI");
         p = new Person("JKL");
         p.setName("MNO");
        System.out.println(p.getName());
     }

The above output is cause of the simple Pass by reference for objects in Java and illustrates how pointers are actually operating without you seeing them.

It is important to remember that when you declare an object like

Person p = new Person("ABC");

p is not the object, it holds a reference to the original object.
When you did p.setName("GHI"); , you actually modified the original object (created in the main) which was pointed to by "p" (local to changePerson() ), But when you did p=new Person("JKL"); , you changed object to which the version of "p" local to changePerson() was pointing to, So now "p" instead of pointing to the object that was created in you main now points to the object that was created in the changePerson() method.

But the change of value of "p" in changePerson() is local to that method cause "p" being a reference is itself passed by value, So the object which "p" points to in the main is never changed and hence GHI is printed in the main.

Sorry I couldn't make it less confusing than that.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

This should help.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now I do not know what to say:

Statement st = null;
ResultSet rs = null;

rs = st.executeQuery("Select description from user ");

Sorry If I sound rude, But do you expect some magic ;) , you are calling the method on an object (st) reference set to NULL, even if the sun doesn't rise tomorrow that code is going to throw a NullPointerException.

peter_budo commented: Sun will rise tomorrow, so there will be NULL +8
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I suggest you use the Tomcat mentioned on here.
If my info is correct Apache Tomcat was known as Jakarta Tomcat back in the days when it was a part of the Jakarta Project (which is also a part of Apache), but now it is a full fledged Apache project and hence the name change to Apache Tomcat. In fact if you check the Jakarta Project home page here, you will see tomcat listed as an Ex-Jakarta project.
The latest version currently available is 6.0.16 and comes bundled with quite a few examples.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

strange .......... i use mingw

did you entered chars not ints ??

I think that was an important information u left out ;)
Yep, it does go into the infinite loop, but so does the first one.

But why exactly its occurring I cant figure it out, I hope some of the other guys know of it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Tried you code out in GCC 4.1.2, no problems, same output for both cases, no infinite loops!!
I had directly copy pasted your code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well the reference Manual on the MySQL site is a pretty good place to start learning MySQL.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Ehh. . . . . Ok Thanks for informing us about it ;)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I already gave you the link to the SMSLib library in my first post

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The best would be get an account from one the many bulk service providers, they should be cheaper, than the GSM Modem option, cause in a GSM Modem you need to insert a SIM and that will be charged for the SMSes you send.

Just google "bulk sms service providers" and you should get a pretty long list of them.
And depending on the provider he might give you a HTTP Link or an SMPP account or both.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you opt for using GSM Modems then SMSLib is a good place to start looking.
An HTTP API would be pretty straight forward to use. For SMPP, the OpenSMPP API would be a very good option.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You need a GSM Modem, or an account with a Service provider who will give you an API, (HTTP link) or may be an SMPP account to connect to his server to send Smses

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

if you are using the latest version of tomcat 6.0+ there is a "lib" folder in the ROOT directory of tomcat, you should find the servlet.jar file there.
In tomcat 5.0 I assume it should be in $CATALINA_HOME/share/lib The second way is to install the J2EE Standard Tools plugin for eclipse.