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 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript function calling a servlet" Watch "javascript function calling a servlet" New topic

javascript function calling a servlet

Stuart Rogers
Ranch Hand

Joined: Oct 02, 2008
Posts: 140
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"> ?


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: 140
By Jove you are correct! Yes this Ajax stuff looks like just the secret sauce I need.


Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: javascript function calling a servlet
jQuery in Action, 3rd edition