wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes javascript function calling a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript function calling a servlet" Watch "javascript function calling a servlet" New topic
Author

javascript function calling a servlet

Stuart Rogers
Ranch Hand

Joined: Oct 02, 2008
Posts: 133
Greetings all,

I've crafted a jsp at http://www.purplelizardgallerycom/show_project_directories.jsp

which contains an <jsp:include "foobar"/> to build the select box,
followed by a button to call a javascript function , followed by an
<div id="clistgoeshere">

Clicking the button triggers the function, which grabs the value picked in the select box and displays it in <div id="clistgoeshere">.

So far so good.

I have a servlet "bohica" that returns some content.

How can I modify the javascript function to call the servlet (something like bohica( projpicked) ) AND have the resulting content displayed in <div id="clistgoeshere"> ?

TIA,

Stuart
Satish Chilukuri
Ranch Hand

Joined: Jun 23, 2005
Posts: 266
What you need is an AJAX call.
Stuart Rogers
Ranch Hand

Joined: Oct 02, 2008
Posts: 133
By Jove you are correct! Yes this Ajax stuff looks like just the secret sauce I need.

Thanks,

Stuart
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Do yourself a favor and, after you familiarize yourself with how Ajax works, adopt a library such as jQuery to handle your Ajax calls for you.

Your hair will thank you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: javascript function calling a servlet
 
Similar Threads
Forwarding the current page to previous page
how to get a variable and print in same page
Speed up Application Created USing Servlets and JSP
jQuery not working on page
Passing parameter from popup