Gaurav wrote:
> MY CODE IS
[snip - incomplete and not compilable jsp]
> I am always gettin the "Answer" as 89, Irrespective what I choose in
> the confirm button.
>
Javascript does not affect the runtime of the JSP. That is, an if
statement has no bearing on the JSP because it (the javascript) is run
on the client - not the server.
If you cut out the HTML (which, at most, is only sent as-is to the
browser), you get:
Answer=1;
Answer=89;
So it's no wonder that, in the end:
> if i choose "True" to my confirm button, First my "Answer" is printed
> as 1 , then it also executes the JSP tag in the "else" clause and makes
> my "Answer" as 89.
>
No. The server executes both because there is no server-side logic to
prevent it. The JSP has finished running long before the browser shows
this to you, however (the server generates the HTML from the JSP which
is sent to the browser as HTML. There is no magic glue that ties the
browser to the JSP).
What you should do is create a page (not some screwey jscript alert)
that says: "the record has been added." and then have a button with a
label "Create new instance". That button would post to another jsp (or
you could write it so that this jsp will handle the click - either way)
and that jsp would handle the semantics of creating a new instance
(whatever that is).
> Kindly help, what is the error ? Is it because I am embeeding JSP in
> Jscript ?
Well, yes. Since you can't *actually* "embed" jsp in jscript.
>
> regards
> gaurav
>
--
Peter MacMillan
e-mail/msn: