• Post Reply Bookmark Topic Watch Topic
  • New Topic

error while trying to access javascript from a java class  RSS feed

 
Akash Thadani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!!

i hava a javascript file that looks like this



and i am trying to call it in my dabmanager class using the following code:




but when i reun it i get thi error: java.lang.NoSuchMethodException: No such function getid()


please help me out guys i can't seem to get hwere the problem is.
Thanks!!
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name of the function is getid, not getid(). If I remove the () I get another exception, about document not being defined. That makes sense because that's a browser defined variable. How can you get the document and an element if the JavaScript is not executed on a web page?
 
Akash Thadani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed () and am getting the same error as Rob is getting can anybody help me find a solution to this please!!
 
Akash Thadani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any other way to do what i am trying to do.. i read about web engines and i found this sample code :



Can someone tell me if i can use this and tell me what changes do i need to make?? Please i really need this to be done and can't seem to figure a way out!!
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you first tell us what you're trying to accomplish? Once we know the "what" we can find the "how".
 
Akash Thadani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a marks.jsp page which contains a marks form. the id select box is populated by data from the database. i want that on selection of a particular id the name corresponding to the id populates the name feild. that is all i want... i am attaching all my code here:

marks.jsp:




my marks servlet class:



and my databae manager file:


the id is getting populated by the database properly the problem is population the name field from the database according to the id selected from the select box.
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget about ScriptEngine etc, you're going to need browser-side JavaScript for this. I'm moving this thread to both HTML/JavaScript and JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, you are barking up a very wrong tree. Forget all about all of that ScriptEngine stuff -- that's not what you are after.

In fact, forget about JSP and Java for the moment too.

What you need to do is to learn how to use JavaScript in HTML pages -- because all JSP does is to specify a template for HTML pages. Your Java code won't know anything about the JavaScript executing on the browser.

The good news is that it's a lot easier to get JavaScript running on an HTML page than all that wrong direction you were headed in. All you need is <script> tags in the JSP (and, of course, to learn JavaScript).
 
Akash Thadani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all the help guy much appreciated!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!