This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 137
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: 137
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: 61103
    
  66

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