• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

embedding javascript into servlet

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear friends,
i'm a fresher and doing aproject.iant to know how can i embed javscript into servlets.pls give a short example.
thanks.
 
Author
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You output JavaScript in exactly the same way as HTML from within your servlets.
An example would be
out.println("<script>alert('this is script')</script>");
If you are making heavy use of javascript, you should probably use JSP pages instead of servlets. Outputing lots of HTML/JavaScript is a very messy process that is prone to errors (quotes will cause you problems) and is very unmaintable.

S
 
reply
    Bookmark Topic Watch Topic
  • New Topic