• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How Do you pass data from the DataBase class back to the servlet?

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps here?

https://jstl.java.net/download.html
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good guess :-) You need javax.servlet.jsp.jstl-api-1.2.1.jar and javax.servlet.jsp.jstl-1.2.1.jar.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And don't forget:
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IT WORKS! IT WORK! IT WORKS!

A screen capture!
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How difficult is it to attach the flight object to its corresponding details button in the same row and then shoot only that object to another JSP page?
 
Sheriff
Posts: 28368
99
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
Not hard at all. The button's URL would just have a parameter containing the flight number.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raymond Gillespie wrote:How difficult is it to attach the flight object to its corresponding details button in the same row and then shoot only that object to another JSP page?



Don't think in term of "attaching the flight object". Once the page is sent to the browser, all objects, all JSP-ness, and all Java-ness is gone. All that remains is the text in the HTML page.

So, as Paul pointed out, you associate something that identifies the item you want associated. That could be something like the flight number, but more often any row of a database will have an id value that has no business meaning. it's just an id. What's best to use depends upon how things are looked up in the database, and how good the database schema designer was.
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Raymond Gillespie wrote:How difficult is it to attach the flight object to its corresponding details button in the same row and then shoot only that object to another JSP page?



Don't think in term of "attaching the flight object". Once the page is sent to the browser, all objects, all JSP-ness, and all Java-ness is gone. All that remains is the text in the HTML page.

So, as Paul pointed out, you associate something that identifies the item you want associated. That could be something like the flight number, but more often any row of a database will have an id value that has no business meaning. it's just an id. What's best to use depends upon how things are looked up in the database, and how good the database schema designer was.



At this point since all this is for practice, the database schema designer is me. Just for the sake of this exercise, I used the flightID as the primary key.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For future reference, it is considered bad schema design to use a business field as a primary key. Generally, the primary key should be a number that has no meaning beyond being a unique identifier for the row. Usually, it's generated by a sequence if the database supports that.

But for now, if your primary key is the flight number, that's what you'd use to identify the item.

The key thing to take away, is that objects never get sent to a page. An HTML page is just that: HTML. So to associate items, you use their primary keys. When the next request comes in, the primary key is used to fetch the object anew.
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SoI could create a hidden form field and have the primary key as an input value this way I could use request.getParameter to grab that value and then get that row from the database.

I am quite sure that would work but doesn't seem/sound like the best way to go about doing that. Seems more like a work around.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it would have been fine 10 years ago -- but these days, JavaScript and Ajax would more likely be involved. But I take it that's not where your head is a t yet, is it?
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Well, it would have been fine 10 years ago -- but these days, JavaScript and Ajax would more likely be involved. But I take it that's not where your head is a t yet, is it?



I know nothing of Ajax. I tried working with it one time on a PHP project but ended up going in a different direction.

I know I can move the text from page to page with JavaScript but I still need to interact with the database and several different servlets as the user goes from page to page. I am basically trying to go through an entire transaction process.

 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript and Ajax do not interfere with that process. But for now, I'd say to stick with just form submissions until you've got all that down pat. Introducing Ajax before that will just make everything harder.

So I'd recommend to go ahead with forms and hidden inputs for now.
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:JavaScript and Ajax do not interfere with that process. But for now, I'd say to stick with just form submissions until you've got all that down pat. Introducing Ajax before that will just make everything harder.

So I'd recommend to go ahead with forms and hidden inputs for now.



Advice taken.

Just want to say thanks for the guidance and advice! It's really nice to be able to ask questions without being belittled when I don't understand something and especially when I do something that makes absolutely no sense what so ever.

I may run into something else so I am sure I will be back.

 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to be of help. Everyone is a beginner in something at one point or another. Unfortunately, not all sites remember that.
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That didn't take long huh. I have noticed that when clicking the back button, the data is gone. How do I make it stick?
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raymond Gillespie wrote:That didn't take long huh. I have noticed that when clicking the back button, the data is gone. How do I make it stick?



EDIT

When I say back button, I refer to the one I created on the page so I should be able to fix that, I hope.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does this back button do, and why do you even have a redundant back button on the page?
 
Raymond Gillespie
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:What does this back button do, and why do you even have a redundant back button on the page?



All it should do is go back to the previous page but of course you are correct in that it is redundant. I just got rid of it.
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic