• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

java code in javascript

 
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

I'm new to javascript. I have a JSP page which has Javascript inside it. Could I put the java code like create an object in Javascript? I try to
do it, but I cannot get the result I excepted.

Thanks in advance!
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use JSP to write JavaScript code, just like you'd do it with HTML.
Remember that JSP runs in the server-side, while JavaScript runs in the browser (client-side).

The following script should work:



Suppose aJSPVariable is the String "Bar". The code's output would be:



JavaScript objects do exist, but they're not commonly used. A JavaScript "class" has the same syntax as a JavaScript "function".



This is advanced JavaScript stuff and, like I said, not frequently used. Since you're a beginner, I think you should focus on learning basic JavaScript and creating dynamic scripts with JSP or Servlets.
 
reply
    Bookmark Topic Watch Topic
  • New Topic