aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Doubt regarding javascript behaviour Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Doubt regarding javascript behaviour" Watch "Doubt regarding javascript behaviour" New topic
Author

Doubt regarding javascript behaviour

rachana ravali
Ranch Hand

Joined: Jun 20, 2006
Posts: 32
Hi ,

i am new to javascript.
i want to set the value of a java variable using the value of a javascript variable.

For example iam writing a function like below:
function test()
{
var test = true;

if(test== true)
{
<% System.out.println("in true");%>
}else if(test == false)
{
<% System.out.println("in false");%>
}
}

here even if the value of test is true ,the code inside the conditional block false is also executed.

i want to know whether we can set variables using conditional blocks using java script.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

This has nothing to do with how JavaScript works but rather, with how the JSP scriplets in your page work.

These scriplets are executed on the server long before the page is sent to the client and the Javascript executes.

This is a critical comcept for you to understand if you are going to be working with JSPs. Please read this article for help in understanding these concepts.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
rachana ravali
Ranch Hand

Joined: Jun 20, 2006
Posts: 32
thank you very much for the link you have gave me Bear Bibeault .
So there is no way to initialize a java variable using a javascript right ?
Please help me if there is any way.
Also can you tell me whether we can maintain the java script variables in session ?

thanks in anticipation.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Originally posted by rachana ravali:
thank you very much for the link you have gave me Bear Bibeault .
So there is no way to initialize a java variable using a javascript right ?
Please help me if there is any way.


Please read the article again. Asking if there is a way indicates that you did not quite understand it.

Also can you tell me whether we can maintain the java script variables in session ?


Only by submitting those values to the server in some way (link, post, Ajax) and have server-side code store the values. You could then restore them during a page refresh or Ajax call.

But as the article points out, JavaScript and server-side code live in different worlds and cannot directly communicate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt regarding javascript behaviour