This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

for loop with insertion query  RSS feed

 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the html page based on for loop we are dropping rows based on number...there its showing all rows step by step .... that's fine..But When i am  writing  insertion query in process page i am getting error only the last row value what i have entered is going inside rest all rows values are not going Any one Please suggest me to how to solve this issue
 
Swastik Dey
Rancher
Posts: 1784
14
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#1.  First of all you should not write java code inside jsp.  It's an very old approach.  JSP should be used for view purpose.  You should ideally use servlet for this.

#2   Without looking at part of your code, it's bit difficult to figure what the issue is.
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





Please see the above Code
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Swastik Dey
Rancher
Posts: 1784
14
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your looking construct looks bit confusing.



What output do you expect?
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actuallyy... The first four input fields are same ..after that it will show drop downmenu based on drop down menu we will select number ..based on that number it will show all rows..now i want to insert those all in one table with different postcodes
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check images
adv-.JPG
[Thumbnail for adv-.JPG]
advselection.JPG
[Thumbnail for advselection.JPG]
 
Swastik Dey
Rancher
Posts: 1784
14
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per this you should retrieve the adv number, start dt, last dt out side loop, and other fields inside loop, and your insertion routine should go inside that loop.
 
Swastik Dey
Rancher
Posts: 1784
14
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should likely to be somewhat like this

 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here I need to write three insertion queries right
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here we are uploading document so we need to use   (  multipart/form-data  ) in front page .. So i think request.getParameter() will not work
 
Dave Tolls
Ranch Hand
Posts: 2554
27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really, do not do this in a JSP page.
That's a mass of code that you will find almost impossible to debug properly.

Move it out into a service that a servlet can call.
The servlet then gathers the data that the JSP will need and then forward to the JSP page.
 
sushma swaraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any way thank you  it worked..Thanks a alot
 
Swastik Dey
Rancher
Posts: 1784
14
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds good.  However as told in few previous posts, you should switch to servlet.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!