• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem pass values from page JSP to another page JSP

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good afternoon. I'm trying to create an application (JSP, MYSQL, CSS) where after the user has correctly logged in, he is directed to a page where he can choose from two select fields, information that will be retrieved from the database and then assembled in a 3rd page, where on this page the user can enter values (information) that will be added to the database. This information is mounted in a table and in this table, in addition to the data retrieved from the database, 10 inputs are added so that these values (information) are sent to the database, after clicking on a button (submit) to save.
Now the questions:
1 - Is it possible to have 2 ResultSet (one to retrieve the data that came from the previous page and another to count the number of records in that table)?
2 - Assuming that the question above is positive, with the number of students, it is possible to create a for loop so that each entry of the table created on the 3rd page for each of the 10 values can be stored in an array (of String or int) and then sent to a last page that will show the result (positive if it managed to persist in the bank or negative if there was a problem)? Here is the structure of the application:

index.jsp
--- receives user login data
--- ok, go to login.jsp

login.jsp
--- sets up 2 select's fields for the user to select bank information
--- sends this information to abreClasse.jsp

openClass.jsp
--- assembles a table with the information passed from the select fields
--- In the table, "input" fields are also created for the data that will be persisted in the database
--- send this information to saveNotes.jsp

saveNotes.jsp
--- tries to persist the data in the database
--- if so, it gives a success message and other options to exit, edit
--- if not, it gives an error message and gives the option to redirect to the beginning of the process (login.jsp)

I have a link to an image of how the table looks after being assembled in the file abreClasse.jsp (with the selection of the select's fields) image link -->(https://flic.kr/ps/42dmnJ). If necessary, I can send the files. The problem is that the way it is (as I did) the values are going with a null value, for the last page. Thanks in advance.
 
Sheriff
Posts: 28331
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those are all perfectly reasonable things to do. Only, choosing to do them in JSPs is not a reasonable thing to do. People would normally choose to do that logic in a servlet and then forward to a JSP to format the result (using JSP EL) into HTML for the user to read.
 
Ricardo Marzano
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Those are all perfectly reasonable things to do. Only, choosing to do them in JSPs is not a reasonable thing to do. People would normally choose to do that logic in a servlet and then forward to a JSP to format the result (using JSP EL) into HTML for the user to read.



Right! Can I show you my codes for you to evaluate?

Thanks for help me and answering!
 
Paul Clapham
Sheriff
Posts: 28331
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post things here if you want to ask about them. But I don't think you need to post the whole lot. I get the impression that the logging-in part is okay. And it isn't clear whether you're having problems generating the data to be displayed in the last output screen or whether you're having problems displaying that data.

It's also possible that you're trying to code everything all at once and that you can't tell where the problem is. It's better to work on one thing at a time before working on the next thing. For example a servlet which does that database extraction and processing is a reasonable unit of work, and a JSP which displays the results is another reasonable unit of work.
 
Ricardo Marzano
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Post things here if you want to ask about them. But I don't think you need to post the whole lot. I get the impression that the logging-in part is okay. And it isn't clear whether you're having problems generating the data to be displayed in the last output screen or whether you're having problems displaying that data.

It's also possible that you're trying to code everything all at once and that you can't tell where the problem is. It's better to work on one thing at a time before working on the next thing. For example a servlet which does that database extraction and processing is a reasonable unit of work, and a JSP which displays the results is another reasonable unit of work.



OK. Now my problem as follow: I can retrive from DB and assemble the table, but when I put some code, return just 1 record. I remove work´s fine again. Is like this:

to get data from user in this page, so if I put this:



only retrive the first record. And this drive me crazy, because I´m stopped at this for 1 week. Thank´s for watching. Regards.
 
Saloon Keeper
Posts: 28325
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't do that.

First of all, it's using scriptlets and that's obsolete. Secondly, not all HTML attributes can be assigned dynamic values using EL. I don't know offhand about "name", but "id" can NEVER be assigned a varying value.

Assuming you want to retrieve database rows in a dispatcher (controller) servlet and display them in an HTML table, forget this complex stuff and look at the JSTL "forReach" tag and its use.
 
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic