• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

embedding javascript into servlet

 
Santosh Tripathi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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.
 
Sam Dalton
Author
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic