File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Financial Year Table

 
Satish Nair
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are plenty of previous examples of iterating through a collection in a JSP in the forum. Search for <c:forEach>
 
Satish Nair
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
FYtable.png
[Thumbnail for FYtable.png]
 
Satish Nair
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator






I have managed to put in the code.....kindly help in editing the same.
 
Satish Nair
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i go ahead to iterate the data and insert the same in the database?
 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database? I thought you were asking about how to display the data via a JSP?
 
Satish Nair
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic