Custom JSP tag helps you implement some programming tricks in Ajax style. This taglib lets you integrate JSP and JavaScript. Right from your JavaScript code you will be able to call server-side stuff (JSP, servlet) with the same idea - update the part of your screen without the reloading the whole page.
More precisely tag jscall lets you create a GET HTTP request to your server-side. Technically this tag defines JavaScript function that will implement HTTP request. Because you are calling from JavaScript your server side must return JavaScript too. It could be just a chunk of JavaScript code added to your page (e.g. some set of functions you will call later) or a real JavaScript call.
For example from our JavaScript code (main page) we are going to call a JSP file that will update the label for the
clicked button on the main page:
here tag tag jscall defines a function f. Any call for this function
will cause GET request to file test.jsp. Arguments will be passed in the query string.
So your test.jsp file looks so:
Note: you do not need <script> brackets in this file!
As you see JavaScript code in test.jsp changes the button (label) on the main page according to the parameter provided in the original JavaScript call:
In the general case created JavaScript function (in our example it is f) will threat own arguments as a set of pairs: name and value in order to provide query string.
And of course our called JSP file can simply load additional JavaScript functions. E.g. in file test.jsp
we can create some function
and in the above mentioned example call it:
Here the first call f() (this function has been defined in the custom JSP tag) loads new JavaScript code and the second call ff() uses this new code.
See also Linked lists description for the practical example.
Tags are:
jscall
Defines JavaScript function that will call server side element (JSP, servlet). Parameters are:
1) name Describes a name for your JavaScript
function
2) url Describes an URI (path) for your JSP (servlet).
for downloading:
Library: jscalltag.jar Description: taglib.tld
See also Coldtags suite - the largest collection of custom JSP tags.