• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Query

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can i pass a mysql query in jsp? And on event of text field change value of another using the query?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey rose,
If u r talking about passing a MYSQL query as a request parameter, then
you can always do that, u need to get the value in the JSP from
request parameter and use that as that for querying the DB.
If u r talking about querying DB from JSP directly, that is also
possible the same way as above except u will be having the query in JSP
rather than getting it from request parameter.
In case if u question is related to something else then better
clearly mention what exactly u r looking for.
Regards,
Javahunk
 
Sheriff
Posts: 67746
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
Welcome to the Ranch JavaHunk!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
Thanks!
bear
JSP Forum Bartender
 
Bear Bibeault
Sheriff
Posts: 67746
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
rose, while you can pass any text to a JSP (including the text of a SQL query), once it gets to the page, there's not much you can do with it. You cannot, for example, cause it to execute from Javascript as the result of a text field event.
All you would be able to do is to submit a new page (or perhaps resubmit the same page) to cause the query to execute back on the server (in which case passing the query to the first page doesn't make much sense).
Perhaps if you described what you are actually trying to accomplsh, we could come up with a way to achieve it.
bear
 
rose hegde
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me make my Q clear.
I have many fields on my jsp form ..the first 2 being emp no and emp name...so what i want is when i enter emp no in the first field..than on change event of that text field ..i want to call a function where i query the database to get the name of that particular emp no and display in next field.
Pls help...
 
Bear Bibeault
Sheriff
Posts: 67746
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
Let me make my answer clear: you can't do it that way.
There is no way you can "call a function" as the result of a client-side event to query the database. You will need to initiate a request to the server in order to perform database access.
bear
 
rose hegde
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Than will u pls tell me how to do it?
 
Bear Bibeault
Sheriff
Posts: 67746
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
There are two basic techniques that you can use:
1) Resubmit the page and fill in the extra information.
2) Submit a request into a hidden iframe, and use the response to generate Javascript that can manipulate your visible page.
bear
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic