wood burning stoves 2.0*
The moose likes JDBC and the fly likes Financial Year Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Financial Year Table" Watch "Financial Year Table" New topic
Author

Financial Year Table

Satish Nair
Greenhorn

Joined: Apr 04, 2012
Posts: 23
Im trying to design a financial year table...wherein the user enters the data in the table and the same is updated in backend.i have successfully desinged the page but i have certain doubts in jsp code.the table is as follows:

MS_target HSD_Target ALPG_Target Lubes_target
april
May
June
July
August
September
october
november
december
january
february
march




The HTML code is fine but im confused on to the JSP part as using an array is not possible.
I have tried using the hastable by creating a hashmap for all the months.


is it fine to use hashmap...or else kindly suggest me to some alternative.I have given names for all fields separately(eg:aprMS,aprHSD,mayMS,mayHSD).also suugest me a code on how to iterate through all the fields.


HashMap april= new HashMap();
april.put("aprMS",new Integer(1));
april.put("aprHSD",new Integer(2));
april.put("aprALPG",new Integer(3));
april.put("aprLubes",new Integer(4));

Like wise i have created hashmap for all months.but i have doubts on how to read the hashmap data and insert the same in database. Kindly help
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
The HTML code is fine but im confused on to the JSP part as using an array is not possible.
I have tried using the hastable by creating a hashmap for all the months.


is it fine to use hashmap...or else kindly suggest me to some alternative.I have given names for all fields separately(eg:aprMS,aprHSD,mayMS,mayHSD).also suugest me a code on how to iterate through all the fields.


You can use any of the collection and set them in request scope through Servlet and then dispatch the request to JSP page. You can then access/iterate these collections through JSTL tags.


hashmap for all months.but i have doubts on how to read the hashmap data and insert the same in database. Kindly help

You can submit the form to a Servlet and get the values submitted through request.getParameter(" ") .
Satish Nair
Greenhorn

Joined: Apr 04, 2012
Posts: 23
Can you give me an example for the former part.....i got the later part.....im a new bie...kindly help....thnanks in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

There are plenty of previous examples of iterating through a collection in a JSP in the forum. Search for <c:forEach>


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Satish Nair
Greenhorn

Joined: Apr 04, 2012
Posts: 23
Thanks for your help(piyush and Bear).As i am a new bie to jsp i understand what you explain but i am finding it difficult to put on code.To get a better picture i would like to explain my project..My project is to design a financial year table where the months are placed on Y axis and The targets are placed on X axis.now the user enters the target details.eg MS_target for the month of april.like wise the target for every field is entered.If suppose the user enters the data for april and clicks on submit the same is updated in table.If after a month the user logs in to enter the details for remaining months the previous data entered should reflect in my page and user can continue entering data for remaining months.


[Thumbnail for FYtable.png]

Satish Nair
Greenhorn

Joined: Apr 04, 2012
Posts: 23






I have managed to put in the code.....kindly help in editing the same.
Satish Nair
Greenhorn

Joined: Apr 04, 2012
Posts: 23
i am srry....i do understand that i jst had to zero in on the code which is not proper....but what i meant was to show you the entrie code so as to what changes could be made to the entire code
Satish Nair
Greenhorn

Joined: Apr 04, 2012
Posts: 23
How do i go ahead to iterate the data and insert the same in the database?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Database? I thought you were asking about how to display the data via a JSP?
Satish Nair
Greenhorn

Joined: Apr 04, 2012
Posts: 23
My primary concern is to store the details in the database entered by the user in my jsp....please help me with an example on how to do the same.....
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you're looking for an example of how to insert data into a database, then choosing to ask that question in the JSP forum was a bad choice. You shouldn't even have code in a JSP which works with a database, that's a job for the servlet which acts as its controller.

But anyway, an example of inserting data into a database: I'm sure you should find an example in Oracle's JDBC tutorial.
 
 
subject: Financial Year Table
 
Similar Threads
jstl request parameter
Reading XML
Java Beginner's I/O Question
Query for Insert data using JSP
Sorting in List<Hash Map>