suppose i have one "table1" in the database.and this table1 having form and action classes.and table2 having also form and action classes
I'm trying to figure out what you are trying to say. Database tables don't have any form or action classes. They only have columns and rows. Basically what I think you are trying to say is that there are two tables, table1 and table2. table1 has two fields- number and name. table2 has a number field and some other fields. Now you want to know the next ID that will be generated in table1 by the database (assuming that number field is incremented automatically in the database). You'll use that next ID that will be generated in table1 on second.jsp. Now first of all what I didn't understand is what is the flow of your application. Is the user first shown one.jsp, and from there they move to second.jsp?? Also what is the exact relationship between table1 and table2. Also if you are going to use that ID that you'll find out, you might face some problems, as there could be more than one people using your application. So if more than one user gets the same value for the number column, then table2 might have two rows with the same value for the number field.
If I'm completely off course, then you can correct me as I couldn't understand what you are trying to do...