• 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

How to show data from database by onmouseover image

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I have got a JSP page, which has a map. On this map there are various cities. I want to display data related to any city, selected by moving cursor over it on the map, picked from database.
How do I do this? Please suggest.
Thanks,
Abhishek
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has nothing to do with JSP, but HTML. You need an imagemap that has entries for your points of interest. That imagemap can (on mouseover) trigger any kind of JavaScript action, e.g. changing a div tag that contains the city data, or displaying some kind of tooltip.
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
That I know, that we can trigger any action using onmouseover, but the problem here is that we have to get the data from database, which will be done by JSP scriptlet only.
Can I call any JSP scriptlet using onmouseover?
Please tell this.
Abhishek
 
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

Can I call any JSP scriptlet using onmouseover?



No. Once the page has been sent to the browser any opportunity to execute Java code is gone. In order to execute server-side code you must submit back to the server.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's one possible way of doing this:

Create a table for each possible city with all the information populated in your jsp. Give each table an id="??name of city??" attribute, and a style="visibilty:hidden;display:none". That way each city's information is in the html document when it is sent to the browser, but none of it is visible on the page. Then you can program the mouseover event of javascript to display the information for a specific city by having it find the appropriate table and changing it's style.visibility and style.display attributes.

The above will work well if there are only a few cities to be displayed, but if there are many, you will want to look for a different solution, as the page will be very large and take a long time to load.

The important thing to remember is that JSP tags can only affect information that is put in the html document before it is rendered into html and sent to the browser. Once the html document is rendered and sitting in the browser, all the information you need has to be there, and the only way of manipulating it is through javascript.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try Using Ajax.
check out this site www.maps.google.com and i think you need something similar.
Search for ajax in the html/javascript forum. plenty has been discussed.
Although as ulf has suggested you need to use image maps to get the mouseover city name.
[ August 05, 2005: Message edited by: Niki Nono ]
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, it is what Ajax is for.
You can call server side stuff right from JavaScript
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With all due respect, this is not a good application for AJAX. Unless we're talking about thousands of cities (or KiloBytes of data per city), it's better to embed the data in the page, either in JavaScript or in invisible elements, much like Merrill suggests. It will be much more responsive that way.
reply
    Bookmark Topic Watch Topic
  • New Topic