• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp and javascript  RSS feed

 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a javascript that gets the value of a form field... how can I pass the parameter to a jsp so that I can perform an sql statement?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why the need for Javascript? Just submit the form to the servlet.
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot because they are on the same page..


There are 2 form fields in the same page.. Both of them fetches data from the.. the second field depends on the value of the first so how can i pass it?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jherald,

It is difficult to tell what you are asking.
Try re-wording your question in a little more detail.
Post the relevant lines of your code.
 
Sathiya Rajamanickam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai
Most of the persons are getting confusion in Java script and JSP communication.
First We must know the order of execution,

1) JSP File is executed by Server and convered into html (May be embedded with javaScript). So We can assign JSP values into Html form fields or assign into javascript varibles directly.All this process is done in server. So Final Output is Html With javascript.

2) html with javascript(Created by the Server)is running in the browser. then how can we set javascript variables again to Jsp. So We cant able to assign Javascript variables value to JSP


Thank You

R. Sathiya
 
ravindra kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Set that value to a form parameter ( might be hidden parameter) and get it in the jsp as a request parameter.
 
andra kan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my understanding,

HTML and Javascript run on client side , So if your form needs to process both Javascript and Servlets, the javascript functions that have
been called will normally execute, and only on form submit, the Servlet will be invoked ( if the form action is the servlet ).

And in the servlet, the form fields can be accessed as request parameters.

In the Javascript the form fields are accessed as form fields only....

Hope this is Useful,
Regards,
Andra
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!