[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

JSP delima --- can not use JavaBean/Servlet

Hi, experts

I am in a delima here. I have to developed something solely JSP without any java classes (Servelt/JavaBean) because the stupid development evnironment I am in right now. No access to server, any class/jar deploy /test will take years....

Anyway, my task is I have to bring back from oracle DB up to 100 rows of data and force user give a setting for the last field of each row and click a submit to do a batch update to the table.

Each row can be identified by a composit key of several fields.

How can I do this. the best way I can figure out is through (preparedStatement and do a addbatch ) in a loop on the action page, then do a executeUpdate().

If I am right on the above. How can I pass the data to the action page? I am thinking I can somehow prepare a serializable Collection object with the resultset data on the first web page and pass it to the action page....

Please let me know your precious idea. just forget about my stupid thought as the above...


Thanks.....................
0
ca_roland
Asked:
ca_roland
1 Solution
 
ca_rolandAuthor Commented:
Sorry, I should have said :


>>if I am right on the above. How can I pass the data to the action page? I am thinking I can somehow prepare a >>serializable Collection object with the resultset data on the first web page and pass it to the action page....


if I am right on the above. How can I pass the data to the action page? I am thinking I can somehow prepare a serializable Collection object "POPULATED BY" the resultset data on the first web page and pass it to the action page....
0
 
KuldeepchaturvediCommented:
Well, I do not think you wd be able to use Collections out here.. Because only way you can show data to User is a HTML page..
So you are bound to use table for this excercise...

Now assuming that user is suppose to update only the last field of the row data, I would use following approach..

While creating the table ( which will be a while loop for sure)... create a hiddenfield and call it (Key+count) here count is a counter thats icrementing with each row..
in the same row name the last field as (value+count)..
At the end of the table store the total rowcount in a hidden variable say ( rowcount)

now upon submit to action page this is how your processing will go..

create a prepared statement... which will look like..
stmt="update table lastfield=? where key=?";

String rowcount = request.getParameter('rowcount");
int count = new Integet(rowcount).intvalue();
for (int i=0; i<count;i++)
{
String key = request.getParameter("key"+i);
String value = request.getParameter("value"+i);
if(key!=null&&value!=null)
{
stmt.setString(key,1);
stmt.setString(value,2);
stmt.execute();
}
}

//end of the processign.

The code I have written above is just  the example, I have checked for the correctness of syntax..
Regards
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now