Like rrz said if you want to pass something from the client (javaScript) to the server (java), you have to submit a form, or use a the name/value query string.
Meaning: your first should look something like:
<form action="validate.jsp">
Enter you value here: <input type="text" name="_value" value="">
Then click the button to Check <input type="Submit" value="Click Me">
</form>
you use that to transfer (or pass if you want) the string value of the _value variable to the validate.jsp page on the server.
The validate,jsp should something like this:
<%
String value = request.getParameter( "_value" ); // get the parameter passed from the client
WebValidiator webValidiator = new WebValidiator(); // create a validator object
// do validation
if( webValidiator.validate( value ) )
{
response.writeln( value + " is a valid value" );
}
else
{
response.writeln( value + " is not a valid value" );
}
%>
Main Topics
Browse All Topics





by: rrz@871311Posted on 2003-07-13 at 16:04:18ID: 8913546
You are mixing things up here. JavaScript is in your client's browser. The java method is at the server. You could use a form to submit the javascript variable to a JSP as a request parameter.