• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling a variable defined in a function in scriptlet  RSS feed

 
vinay paandey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need a help.

I am getting a variable value in a function like

function myfun ()
{
var formHandle = document.forms["myvar"];
var location = formHandle.location.value;
}

Now i want to pass the var location in a scriptlet like

<%

MyClass a = new MyClass(location)

%>

Is this possible. If so how. Kindly help me in this regard.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not possible. JavaScript on the client executes not only on a different system, but long after the JSP has finished executing. Please read this article to understand how JSP operates and why this is impossible.

By the way, putting Java scriptlets into a JSP is a bad practice that has been obsolete for 12 years; why are you using scriptlets?
 
vinay paandey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear

Thanks for replying...
I am looking for some way to populate a table from database based on the value that get selected from a drop down list on a jsp page. The problem is the existing code is written in such a way that the selected value can be accessed only in a function using
var formHandle = document.forms["myvar"];
var location = formHandle.location.value;

If you don't mind, then can you suggest an efficient way of doing it?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!