Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

set java variable in javascript function

 
vaibhav thorat
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a code like this :

test1.jsp


what I want is, when i click on "OK" button, value of "flag" should be tested and according to the result page "test2.jsp" get included.
code is doing fine ...
but...
As soon as I open page "test1.jsp", flag becomes 1. and page "test2.jsp" get loaded ....
How come I overcome this situation ?


- Vaibhav
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to mix server-side and client-side actions and that, of course, can never work.

The JSP executes on the server, long before the page gets sent to the browser where the JavaScript can be evaluated.

Please read this article to understand how JSP operates. You should not write one more line of code until you understand what JSP is and what JSP is not.

If you want to dynamically include page fragments as the result of a client action, then you'll need to use Ajax.
 
vaibhav thorat
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Will definitely read that.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This comes up so often that I've finally created a JspFaq entry for it: CanIMixJSPWithJavaScript
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!