File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Help ME PLZ. Very Soon.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Help ME PLZ. Very Soon.." Watch "Help ME PLZ. Very Soon.." New topic

Help ME PLZ. Very Soon..

sreekanth rach

Joined: Jan 02, 2003
Posts: 14
Hi Friends!!
How can i use JavaScript Variable within JSP page..
like my requirement is, i want to use that JavaScript variable in a SQL-query (everything within JSP page)..
plz look into this code below..
--code start--

--code end--
in the above code, how can i use JavaScript variable (str1_mod) outside the html page in a query while preparing servlet code(observe the query)...if i run the above code, 'am getting compilation error of UnKnown Variable str1_mod ..
'am using Tomcat4.1.18 server..
'am in real-need of you..
Kindly Help me Plz..
thanks in advance,to everyone,
anticipating replies very eagerly..
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i didn't check your complete code, but as far as i understood you want to use a Javascript variable in a JSP.
The way you are trying to do this will never work, cause the JSP code is executed on server side and your javascript on client side. This means
while the JSP is created and delivered to the client. Then on client side
the Javascript variable is set.
Try to create a form which has another JSP or Servlet as action. To this
you pass the content of your Javascript variable over some parameter in the URL (GET) or within a hidden field you filled with your javascript code.
Hope that helps you out
I agree. Here's the link:
subject: Help ME PLZ. Very Soon..
jQuery in Action, 3rd edition