This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Hyperlink click error processing" Watch "Hyperlink click error processing" New topic
Author

Hyperlink click error processing

James Winfrey
Ranch Hand

Joined: Jan 04, 2009
Posts: 60
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?

Thanks


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
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.


Ping & DNS - my free Android networking tools app
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hyperlink click error processing
 
Similar Threads
Hyperlink and submit
Href in my JSP
how to access value from a page
HttpServletRequest got lost
s:url and s: question