File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP functions

 
Karl Dowling
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have list box in a form that is pulling data from a mysql db. when i click on an item in the list box i want data to change in other text boxes in the form. i have most of the code to it......BUT... i need to put that code into a function and call it in the onChange event in the form. i have tried to do this but ikeep getting the following error:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 18 in the jsp file: /Administrator/addPromotion.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\tomcat\work\Catalina\localhost\_\org\apache\jsp\Administrator\addPromotion_jsp.java:84: ';' expected
function ChangeDynamicData(){
^
1 error

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
im just not too sure how to structure my function and how to call it.
any replies would be greatly appreciated!!
cheers
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are mixing up Java functions and Javascript functions. The onchange handler requires a Javascript function.
 
Karl Dowling
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok,
is there a way to refresh the browser in the onChange event?
 
Winston Smith
Ranch Hand
Posts: 136
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do this all with javascript, you want to stay away from JSP for this one. Your onChange() event is controlled by javascript, so, in your onChange() function, you can simply use javascript to replace the values in the fields you want to change. So for instance, assume I have the following bit of code:

When you click the button, the text in the textarea will change. You can use these scheme to change DOM components dynamically.
NOTE: onKlick() has been changed to conform to the Ranch posting requirements -- it should be spelled with a C, of course.
[ April 01, 2004: Message edited by: Winston Smith ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quite correct; there is no need for server-side activity to accomplish this.
I'm moving this to the HTML/Javascript forum for any further discussion.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
refreshing the browser:
onclick="document.location.href=document.location.href"
or
onclick="document.location.reload()"
[ April 01, 2004: Message edited by: Eric Pascarello ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic