File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Hyperlink click error processing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Hyperlink click error processing" Watch "Hyperlink click error processing" New topic

Hyperlink click error processing

James Winfrey
Ranch Hand

Joined: Jan 04, 2009
Posts: 62
Hi Guys

I have a jsp on which I dispaly table of hyperlinks.

On click of hyperlink I have to do some processing in a servlet and display an error mesage on jsp if something goes wrong.

but the control should remain on the same jsp.

Is this possible without submitting the page?


Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Sounds like a perfect application for AJAX. Libraries like Prototype and jQuery make it easy to kick off a request, collect the result, and update the HTML page accordingly without actually leaving the page.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63857

Example using jQuery:

Or, you could write a couple of pages of raw JavaScript to do the same...

The example code above doesn't account for error handling, but that's just a few more lines (which I didn't add for clarity) that we can discuss if you go this route.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Hyperlink click error processing
jQuery in Action, 3rd edition