Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2006, 04:40 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default calling a servlet by clicking a menu?

Dear Friends ,


            i want to call a servlet by clicking a menu. please help me

regarding this.............
 
Old February 4th, 2006, 10:28 AM
Authorized User
 
Join Date: Jan 2006
Location: , , USA.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to longjava
Default

Here is how you would call a servlet when a user clicks on the menu:

(Assuming that the menu is made of CSS and HTML, and the menu item is an anchor html tag <a>)

<html>
<head>
<script type='text/javascript'>
function invokeServlet()
{
   // form a URL with the servlet name to be invoked
   var URL = 'http://hostname/servlet/servletName';

   // This line will inkove a servlet and reload your page
   location.href = URL;
}
</script>
</head>
<body>

<a href='#' onclick='invokeServlet()'>Click here to invoke servlet</a>
</html>






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in calling classes in simple Servlet sanna231 J2EE 6 December 23rd, 2012 01:06 AM
Calling java Servlet from ascx page pradeepnair74 BOOK: ASP.NET AJAX Programmer's Reference : with ASP.NET 2.0 or ASP.NET 3.5 ISBN: 978-0-470-10998-4 0 October 7th, 2008 07:31 AM
Calling a btn_click method without clicking it dhirajDac VB.NET 1 April 18th, 2008 08:24 AM
Calling a command from a servlet emirant1 Servlets 1 December 23rd, 2005 11:33 AM
calling java servlet from javascript bearfacts Javascript How-To 1 August 26th, 2004 04:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.